Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Do you know a way to find out a scroll position in JS or jQuery on a page in Sharepoint 2010? I have a web part that is very big (high) so scroll on the page appears. But I cannot determine the scroll position in any known way using javascript - it is always 0

self.pageYOffset; 
document.documentElement.scrollTop; 
document.body.scrollTop;

all return 0. I cannot get through this. I think sharepoint is to blame. Is there any way to find out?

share|improve this question
add comment

2 Answers

By default SharePoint page divided on two areas: static header (where are ribbon row and top bar) and workspace. Header is always on top and you scrolling in workspace area only, but not in whole page. So you need to know scroll possition in worspace area. You can make it with this javascript code:

document.getElementById("s4-workspace").scrollTop
share|improve this answer
    
This should work--as IAdanasov points out, the default behavior of SP2010 is that the body doesn't scroll. You can certainly disable this if you've done customizations to your branding, but out of the box, you want the scroll position of the 's4-workspace' div. –  webdes03 Feb 29 '12 at 15:25
add comment

Try one of these, I believe they might help you:

  1. how-do-i-determine-height-and-scrolling-position-of-window-in-jquery
  2. get-current-scroll-position-and-pass-it-as-a-variable-with-a-link
share|improve this answer
    
tried them to no avail; it's the same thing i suppose –  agnieszka Jan 17 '12 at 14:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.