JavaScript get scrollbar height + Common JS page width and height

Source: Internet
Author: User

/* ******************* * Get window scrollbar height  ******************/function  getscrolltop () {     var scrolltop=0;     if (document.documentelement&&Document.documentElement.scrollTop)    {        scrolltop=document.documentElement.scrollTop;    }     Else if (document.body)    {        scrolltop=document.body.scrollTop;    }     return scrolltop;}
/******************** * Gets the height of the window's viewable range *******************/functiongetclientheight () {varClientheight=0; if(document.body.clientheight&&document.documentElement.clientHeight) {varClientHeight = (document.body.clientheight<document.documentelement.clientheight)?Document.body.clientHeight:document.documentElement.clientHeight; }    Else    {        varClientHeight = (document.body.clientheight>document.documentelement.clientheight)?Document.body.clientHeight:document.documentElement.clientHeight; }    returnclientheight;}
/* ******************* * Get document content actual height  *******************/function  getscrollheight () {    return  Math.max (document.body.scrollheight,document.documentelement.scrollheight );}

////////////////////////////////////////////////////

In ie:
document.body.clientWidth ==> Body Object width
document.body.clientHeight ==> Body Object Height
document.documentElement.clientWidth ==> Visible area width
document.documentElement.clientHeight ==> Visible area height
in Firefox:
document.body.clientWidth ==> Body Object width
document.body.clientHeight ==> Body Object Height
document.documentElement.clientWidth ==> Visible area width
document.documentElement.clientHeight ==> Visible area height
?
in Opera:
document.body.clientWidth ==> Visible area width
document.body.clientHeight ==> Visible area height
document.documentElement.clientWidth ==> The width of the page object (that is, the body object width plus the margin width)
document.documentElement.clientHeight ==> Page object height (i.e. body object height plus margin height)
and if there is no standard to define the
IE is:
document.documentElement.clientWidth ==> 0
document.documentElement.clientHeight ==> 0
Firefox is:
document.documentElement.clientWidth ==> Page object width (that is, body object width plus margin) Document.documentElement.clientHeight = = height of the Page object (that is, the body object height plus the margin high)
Opera is:
document.documentElement.clientWidth ==> Page object width (that is, body object width plus margin) Document.documentElement.clientHeight = = height of the Page object (that is, the body object height plus the margin high)
really a troublesome thing, in fact, in terms of development, rather fewer objects and methods, do not use the latest standards to facilitate many AH.

//////////////////////////////////////////////////////////////////////////////////////

width of visible area of Web page:
Document.body.clientWidth

Web page Visible Area High:
Document.body.clientHeight

width of visible area of Web page:
Document.body.offsetWidth (including the width of the edge)
Web page Visible Area High:
Document.body.offsetHeight (including the width of the edge)

page Body Full text width:
Document.body.scrollWidth
page Body Full text High:
Document.body.scrollHeight

the page is rolled away High:
Document.body.scrollTop
webpage is rolled away left:
Document.body.scrollLeft

on the body part of the webpage:
Window.screentop
page body part left:
Window.screenleft

High screen resolution:
Window.screen.height
width of screen resolution:
Window.screen.width

screen usable workspace height:
Window.screen.availHeight
screen Usable workspace width:
Window.screen.availWidth

JavaScript get scrollbar height + Common JS page width and height (rpm)

Related Article

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: info-contact@alibabacloud.com 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.