I am displaying the value of document.body.scrollTop in the status bar while moving the mouse. The value is always 0 in IE. Why is always 0? Is there another way to get how much the scroll bar has moved?
scrollTop property gets or sets the number of pixels that an element's content is scrolled vertically. An element's scrollTop value is a measurement of the distance from the element's top to its topmost visible content. When an element's content does not generate a vertical scrollbar, then its scrollTop value is 0 .
scrollTop is deprecated in strict mode.
Generally you can use (document. documentElement. scrollTop || document. body.
jQuery scrollTop() Method The scrollTop() method sets or returns the vertical scrollbar position for the selected elements. Tip: When the scrollbar is on the top, the position is 0.
You may want to try this for an older doctype in IE:
var top = (document.documentElement && document.documentElement.scrollTop) || document.body.scrollTop;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With