2

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?

0

2 Answers 2

7

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
1
  • 1
    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, 2012 at 15:25
0

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
1
  • tried them to no avail; it's the same thing i suppose
    – agnieszka
    Jan 17, 2012 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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