<Style type = "text/css">
Body {width: 1500px; height: 1500px; padding-top: 200px}
</Style>
Add this style to make
WebpageForm scrolling
1. Why?Document. Body. scrollTop is always 0?
Understanding:
First:
Not added at the top of the document <! DOCTYPEHtmlPUBLIC "-// W3C // DTDXHTML1.0 Transitional // "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<Html xmlns = "http://www.w3.org/1999/xhtml">, isBodyFor the document root element, because document.body.scrolltopic is valid, not 0, and document.doc umentElement. scrollTop is 0.
When you addDoctypeThe Declaration is based on the html element as the root element. Therefore, document. body. scrollTop is always 0,
Use document.documentelement.scrolltop(document.doc umentElement is the object of the html element)
The code can be written as follows:
VarScrolltop= Document. compatMode = "CSS1Compat "? Document.doc umentElement. scrollTop: document. body. scrollTop;
Understanding of document. compatMode
Obtain the current document rendering method. When the document has a standard declaration, the document. the value of compatMode is equal to "CSS1compat". Therefore, we can. compatMode value to determine whether a standard declaration is added to the document
Second point:
Documents must be rolled out
<Input type = "button" value = "body. scrollTop" onclick = "alert(document.doc umentElement. scrollTop)"/>
Summary:
1. The current webpage is basically declared <! DOCTYPE html generally uses document.doc umentElement. scrollTop and document.doc umentElement. scrollWidth.
Download the complete case: the deep-seated parameter is document.body.scrolltopic, Which is 0 million. rar (1.09 KB)
From: http://www.eyejs.com/html/29/n-29.html