Http://www.jb51.net/article/23331.htm
JavaScript gets the height of the page and the position of the scroll bar in the code font: [Increase decrease] Type: Reprint JavaScript to get the height of the page and scroll bar position code, the need for friends can refer to the next.Copy CodeThe code is as follows:
var viewport={
Top:function () {
Return Window.pageyoffset
|| Document.documentelement && Document.documentElement.scrollTop
|| Document.body.scrollTop;
},
Height:function () {
Return Window.innerheight
|| Document.documentelement && Document.documentElement.clientHeight
|| Document.body.clientHeight;
},
Left:function () {
Return Window.pagexoffset
|| Document.documentelement && Document.documentElement.scrollLeft
|| Document.body.scrollLeft;
},
Width:function () {
Return window.innerwidth
|| Document.documentelement && Document.documentElement.clientWidth
|| Document.body.clientWidth;
},
Right:function () {
return Viewport.left () + viewport.width ();
},
Bottom:function () {
return Viewport.top () + viewport.height ();
}
};
Center:
Copy CodeThe code is as follows:
style.position= "Absolute";
style.left=50%;
Style.top=viewport.top () +viewport.height ()/2+ "px"; Articles you may be interested in:
Code that JavaScript gets the height of the page and the position of the scroll bar