How to Get javascript code for browser page area size _ javascript skills

Source: Internet
Author: User
How to obtain the area size of the browser page is as follows:

The Code is as follows:


// Available in IE, FireFox, and Opera
Document. body. clientWidth
Document. body. clientHeight
// It can be obtained, which is very simple and convenient.
// In the company project:
// Opera is still in use
Document. body. clientWidth
Document. body. clientHeight
// However, IE and FireFox use
Document.doc umentElement. clientWidth
Document.doc umentElement. clientHeight
// It turned out to be W3C standards.
// Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
// If this line is added to the page

// In IE:
Document. body. clientWidth ==> BODY object width
Document. body. clientHeight ==> BODY object height
Document.doc umentElement. clientWidth ==> visible area width
Document.doc umentElement. clientHeight => visible area height
// In FireFox:
Document. body. clientWidth ==> BODY object width
Document. body. clientHeight ==> BODY object height
Document.doc umentElement. clientWidth ==> visible area width
Document.doc umentElement. clientHeight => visible area height
?
// In Opera:
Document. body. clientWidth ==> visible area width
Document. body. clientHeight ==> visible area height
Document.doc umentElement. clientWidth ==> Page Object width (that is, the width of the BODY object plus the Margin width)
Document.doc umentElement. clientHeight ==> Page Object height (that is, the height of the BODY object plus the Margin height)
// If W3C standards are not defined
// IE:
Document.doc umentElement. clientWidth ==> 0
Document.doc umentElement. clientHeight => 0
// FireFox:
Document.doc umentElement. clientWidth ==> Page Object width (that is, adding the bodyobject width to the marginwidth) document.doc umentElement. clientHeight ==> Page Object height (that is, the BODY object height plus the Margin height)
// Opera:
Document.doc umentElement. clientWidth ==> Page Object width (that is, adding the bodyobject width to the marginwidth) document.doc umentElement. clientHeight ==> Page Object height (that is, the BODY object height plus the Margin height)

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.