Home > Web Front-end > JS Tutorial > body text

js method to obtain browser page area size_javascript skills

WBOY
Release: 2016-05-16 17:22:06
Original
1062 people have browsed it

Get the size of the browser page area:

Copy the code The code is as follows:

//In IE , FireFox and Opera can use
document.body.clientWidth
document.body.clientHeight
// to get it, very simple and convenient.
//In company projects:
//Opera still uses
document.body.clientWidth
document.body.clientHeight
//But IE and FireFox use
document .documentElement.clientWidth
document.documentElement.clientHeight
//It turns out that the W3C standard is causing trouble
//http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional. dtd”>
//If you add this line of tags to the page

//In IE:
document.body.clientWidth ==> BODY object width
document. body.clientHeight ==> BODY object height
document.documentElement.clientWidth ==> 🎜>document.body.clientWidth ==> BODY object width
document.body.clientHeight ==>gt; 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 ==> Page object width (that is, BODY object width plus Margin width)
document.documentElement.clientHeight ==>gt; Page object height (that is, BODY object height plus Margin width) High)
//If there is no W3C standard defined, then
//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 width) document.documentElement.clientHeight ==>; Page object height (i.e., BODY object height) Plus Margin height)
//Opera is:
document.documentElement.clientWidth ==> page object width (that is, BODY object width plus Margin width) document.documentElement.clientHeight ==> page object height (That is, the height of the BODY object plus the height of the Margin)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!