How to get width and height of monitor, browser and window in JS

Source: Internet
Author: User

Web page Visible area width: document.body.clientWidth

Web page Visible Area height: document.body.clientHeight

Web page Visible Area width: document.body.offsetWidth (including edge width)

Web page Visible Area High: document.body.offsetHeight (including edge width)

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

Screen available work area height: window.screen.availHeight

Screen available work area width: window.screen.availWidths

HTML Precise 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 scrolling width of the object

Offsetheight: Gets the object relative to the canvas or by the parent coordinate

The height of the parent coordinate specified by the OffsetParent property

Offsetleft: Gets the object relative to the layout or by the

The OffsetParent property specifies the parent coordinate of the computed left position

OffsetTop: Gets the object relative to the layout or by the

The OffsetTop property specifies the top position of the calculated parent coordinate

Event.clientx horizontal coordinates of relative documents

Event.clienty vertical coordinates of relative documents

Event.offsetx horizontal coordinates relative to the container

Event.offsety the vertical coordinate of the relative container

Document.documentElement.scrollTop The vertical scrolling value

Event.clientx+document.documentelement.scrolltop horizontal coordinates of relative documents + amount of vertical scrolling

Ie,firefox differences are as follows:

IE6.0, ff1.06+:

clientwidth = width + padding

clientheight = height + padding

offsetwidth = width + padding + border

offsetheight = height + padding + border

Ie5.0/5.5:clientwidth = Width-border

ClientHeight = Height-border

offsetwidth = width

offsetheight = height

(Need to mention: the Margin property in CSS, and clientwidth, Offsetwidth, clientheight, offsetheight are irrelevant)

Web page Visible area width: document.body.clientWidth

Web page Visible Area height: document.body.clientHeight

Web page Visible area width: document.body.offsetWidth

(including width of edges) Web page visible area height: document.body.offsetHeight

(including high edges) 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

Screen available work area height: window.screen.availHeight

Screen available work area width: window.screen.availWidth

How to get width and height of monitor, browser and window in JS

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.