Description of the API for height and width in javascript

Source: Internet
Author: User

In the JavaScript world, there are many APIs that seem to help us know the width and height of web pages , but they are too numerous and easy to confuse and not easily differentiate. Let me explain what these APIs mean, and where the difference is.

First, the resolution of the device

Window.screen.widthxwindow.screen.height

Desktop: 1440x900/Mobile: 360x640

Second, the resolution of the browser

Window.screen.availWidthxwindow.screen.availHeight

Desktop chrome:1440x860/Mobile: 360x640

Devices and browsers installed on the device do not change as long as they are not changed, their resolution remains the same

In a desktop device, the height of the browser resolution = the height of the device resolution-40px; the width of the device resolution contains the scroll bar width

Three, the window viewport (can see the page area) of the width of the high


Desktop chrome:1440x797/Mobile: 360x518

Window.innerwidth the width of the scrollbar in the desktop device, and the Window.innerheight changes as the menu and the bookmarks Bar are hidden and displayed

IE8 does not support these two properties

You can use these two properties as the basis for a responsive layout

Iv. width and height of document files

Finish

 

Description of the API for height and width in javascript

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.