The script cannot obtain the actual scrolltop value.

Source: Internet
Author: User

To obtain the ordinate position of the scroll bar of the current page, use:
Document.doc umentelement. scrolltop;
Replace: Document. Body. scrolltop;

Documentelement corresponds to an HTML Tag, while the body corresponds to a body tag. Sometimes the value of the body is always 0. In this case, you only need to change it to documentelement. The document.doc umentelement attribute is provided only after ie5.0.
Documentelement is a new attribute and is not commonly used in the past. This is easy to make mistakes during development. Many examples on the Internet are old and document. Body. scrolltop is used. In fact, the correct value is not obtained, and the obtained value is always 0.

I have encountered this problem before. I don't know if it is an IE bug. When I use the Treeview control and put the Treeview in the frame, the problem may occur. In some cases, I may only use the document. body. scrollleft cannot obtain the actual value of the position of the scrollbar. the return value is always 0. Sometimes this kind of softness is intended for compatibility, because the document.doc umentelement attribute is provided after ie5.0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.