Home  >  Article  >  Web Front-end  >  Why is document.body.scrollTop always 0 in IE, even when scrolling?

Why is document.body.scrollTop always 0 in IE, even when scrolling?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-17 07:52:03470browse

Why is document.body.scrollTop always 0 in IE, even when scrolling?

document.body.scrollTop in IE is always 0, even when scrolling

When you move the mouse, in the status bar Display the value of document.body.scrollTop. In IE, this value is always 0. Why is it always 0? Is there any other way to get how much the scrollbar has moved?

To resolve this issue, for older document types in IE, you can try the following:

var top = (document.documentElement && document.documentElement.scrollTop) || 
              document.body.scrollTop;

The above is the detailed content of Why is document.body.scrollTop always 0 in IE, even when scrolling?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn