JS Gets the height and width of the browser

Source: Internet
Author: User

Recently finishing up to see some of the previous essays, sent to think about, to commemorate the once bitter force of the learning journey;

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

OperaIn
Document.body.clientWidth ==>Visible area Width
Document.body.clientHeight ==>Visible area Height
Document.documentElement.clientWidth ==>Page object width (that is,BODYObject Width PlusMarginWide
Document.documentElement.clientHeight ==>The height of the page object, which isBODYObject Height PlusMarginHigh
Not definedW3cThe standard, then
IeFor:
Document.documentElement.clientWidth ==> 0
Document.documentElement.clientHeight ==> 0
FireFoxFor:
Document.documentElement.clientWidth ==> the width of the Page object (that is, the BODY object width plus the Margin width ) Document.documentelement.clientheight==> the height of the Page object (that is, the BODY object height plus the Margin High)
Opera is:
Document.documentElement.clientWidth ==> the width of the Page object (that is, the BODY object width plus the Margin width ) Document.documentelement.clientheight==> the height of the Page object (that is, the BODY object height plus the Margin high)


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 (Include the width of the edge)
Web page Visible Area High:document.body.offsetHeight ( including edge height )
Page body Full text width:document.body.scrollWidth
Page body Full text High:document.body.scrollHeight
Page is rolled away High:Document.body.scrollTop
Webpage is rolled away left: document.body.scrollLeft
Page body part: window.screentop
Page body part left: window.screenleft
High screen resolution: Window.screen.height
Width of screen resolution: Window.screen.width

HtmlPrecise positioning: Scrollleft,scrollwidth,clientwidth,offsetwidth
ScrollHeight:Gets the scroll height of the object.
ScrollLeft:Sets or gets the distance between the left edge of the object and the leftmost of the currently visible content in the window
ScrollTop:Sets or gets the distance between the top of the object and the top of the visible content in the window
Scrollwidth: Gets the scroll width of the object
Offsetheight: Gets the height of the parent coordinate specified by the object relative to the canvas or by the parent coordinate offsetparent
Offsetleft: Get object relative to layout or offsetparent
Offsettop: Gets the object relative to the canvas or by the Offsettop
Event.clientx relative document horizontal coordinates
Event.clienty relative to the vertical coordinates of the document
Event.offsetx relative to the container's horizontal coordinates
Event.offsety The vertical coordinate of the relative container
Document.documentElement.scrollTop vertical scrolling value

JS Gets the height and width of the browser

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.