JavaScript get scrollbar height + Common JS page width and height

Source: Internet
Author: User

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

/********************
* Take window scroll bar 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;
}


/********************
* Take the height of the window visible range
*******************/
function Getclientheight ()
{
var clientheight=0;
if (document.body.clientheight&&document.documentelement.clientheight)
{
var clientheight = (document.body.clientheight<document.documentelement.clientheight)? Document.body.clientHeight:document.documentElement.clientHeight;
}
Else
{
var clientheight = (document.body.clientheight>document.documentelement.clientheight)? Document.body.clientHeight:document.documentElement.clientHeight;
}
return clientheight;
}

/********************
* Take the actual height of the document content
*******************/
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 (i.e. body object width plus margin) Document.documentElement.clientHeight = = > Page object height (i.e. body object height plus margin)
Opera is:
Document.documentElement.clientWidth ==> Page object width (i.e. body object width plus margin) Document.documentElement.clientHeight = = > Page object height (i.e. body object height plus margin)
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

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.