document.body.scrollTop OR document.documentElement.scrollTop.though I havent tried this in IE 7 because all I have here is IE6 but Im told it fixes the problem when using IE 7/XP however, MOZ on an XP box still has the problem? .scrollTop(): document proper use of scrollTop on document body 425.I think thats why it sat around so long, it is tedious to sort through these kinds of tickets and there is always concern youll upset someone by ignoring their concerns. In firefox element.scrollTop is always giving me 0 In IE this is giving the right value. what is the scrollTop equivalent in Firefox.I have the same problem. Im calling: alert(window.pageYOffset) alert( document.body.scrollTop) st (html,body).scrollTop() // jQuery call For some reason, removing height: 100 from my html and body tags fixed this issue. I hope this helps someone else! (document).scrollTop() always returns 0. Im simply trying to do something once the scroll position of the page reaches a certain height.had the same problem. scrollTop() works with some block not document or body. However no matter what I do it always seems to return 0. Any ideas?0) position [ document.
documentElement.scrollLeft, document.documentElement.scrollTop ] else if (typeof document.body.scrollTop ! undefined) position else if (document.documentElement document.documentElement.scrollTop ).Just take a peek at the source code to see that all it takes is a setting of height:100 for the body (with overflow-y:auto) and it works. Firefox 17, Opera 12 IE 10 document.
body.scrollTop - always returns 0 document.documentElement.scrollTop - returns the scrollbar location on screen. Meaning, webkit vs non-webkit browser swap the values returned. Ive got a page which contains the button that calls document.location.reload() when clicked. When reloading the page I get the value of ( document).scrollTop().In Firefox and Opera scrollTop() returns correct value. And in Chrome and IE always returns 0. If you want to get or set the vertical scroll position of a document, you can use element. scrollTop.In quirks mode you would use the
element, via document.body. This works in IE and Firefox and the late Presto Opera. If I change (body).scrollTop() to (document).scrollTop() then I get a null return on scroll.(document).scrollTop() always returns 0. Im simply trying to do something once the scroll position of the page reaches a certain height. Meanwhile I created a very simple HTML page with a lot of 0) st window.pageYOffset else if ( document.documentElement.scrollTop > 0) stEven in chrome console when i this code in console it is not working. enter code here (html, body).stop().
animate( scrollTop: 50 , 500) document.body.scrollTop this function provides a cross-browser implementation of reading the scroll offsetDepending on the DOCTYPE, you would have to use document.body.scrollTop or document.documentElement.scrollTop. However after trying to figure out why the script wasnt working I used document.body.scrollTop to find it always returned a value of 0 despite having a larger scroll height. Definition and Usage. The scrollTop property sets or returns the number of pixels an elements content is scrolled vertically.function myFunction() var scrollpercent (document.body.scrollTop document.documentElement.scrollTop) / (document.documentElement.scrollHeight Chrome and Safari always use document.body.scrollTop, while IE and Firefox use document.body.scrollTop for quirks mode and document.documentElement.scrollTop for standard mode. Your best bet may be something like If I use the transitional 4.01 doctype, document.body.scrollTop always returns zero (in Win IE 6), no matter the scrolling of the page (works fine in FF, Opera.) Actually, I got both situtations to work reasonably well by reverting to the 3.2 doctype. Upon rendering the page, i have the scroll bars (vertical) enabled. I can able to scroll it. but the JS calls, document.body.scrollLeft and document.body.scrollTop are always giving 0 (Zero). I am testing this with IE. I am displaying the value of document.body.scrollTop in the status bar while moving the mouse.Why is always 0? Is there another way to get how much the scroll bar has moved? is it 3,3333 and -3,3333 always constant and as result of forward and backward scroll? then you can replace my -1 value with those which associate with forward scroll.Ive changed all window.scrollTo( 0,document.body.scrollTop px ) to window.scrollBy( 0, -px) js scrollTop. A Pen By yakyu.var bdy document.body var arw document.querySelector(.arrow-top) After some mucking around, I discovered that the document.body.scrollTop is always returning zero regardless of where the scrollbar is. The same thing is happening for the window.pageYOffset in firefox. document.body.scrollTop Wide support, but deprecated in strict mode.To start things off I grab some variables and geometry as its always good to do the least amount of work inside a scroll handler (performance reasons). Use the properties scrollTop and scrollLeft to get or set the scroll position of an element: var el document.querySelector(div)Setting the document scroll position of the document in px: document.documentElement.scrollTop document.body.scrollTop 1000 But document.body.scrollTop or document.documentElement.scrollTop always returns 0 becuase of the way scrolling has been handle in masterpage. Can anyone help me with this issue? You must add document.body scrolling factors to align event coordinates with body content positions. Starting with IE 5 for Windows, the scrollLeft and scrollTop properties are available for all HTML element objects, but values for unscrollable elements are zero. if no doctype is specified in the document, the scrollTop property of the html element always returns zero.Otherwise, the documentElement will not represent the body of the html page and 0 will be returned for the scrollLeft and scrollTop elements. Why is always 0? Is there another way to get how much the scroll bar has moved?Depending on the DOCTYPE, you would have to use document.body.scrollTop or document.documentElement.scrollTop. please check out the code snippet.firefox works in the right way, but safari and chrome dont.is it a bug or something? how to prevent that? document.body.addEventListener(scroll, function() console.log(this.scrollTop))html height: 10 document.body.scrollTop always is 0. Reported by yhsiappier.com, Sep 20.What went wrong? document.body.scrollTop do not return the right value when you scrolling the window. Did this work before? document.body.clientWidth document.body.clientHeight document.body.scrollLeft document.body.scrollTop. IE. Win32.Above code worked with all the browsers I could get ahold of (and usually those are the only ones you should worry about), but there is always the possibility of the Element properties that provide width, height and other geometry are always numbers.Setting scrollTop to 0 or Infinity will make the element scroll to the very top/bottom respectively.let elem document.body