当前位置:网站首页>How to get the size of browser page area

How to get the size of browser page area

2020-12-08 09:53:33 Silence is emptiness

How to get the size of the browser's page area :

// stay IE、FireFox、Opera You can use it all the time
document.body.clientWidth
document.body.clientHeight
// You can get , It's simple , Very convenient .
// And in company projects :
//Opera Still use
document.body.clientWidth
document.body.clientHeight
// But IE and FireFox Then use
document.documentElement.clientWidth
document.documentElement.clientHeight
// Turned out to be W3C The standard is making a mistake
//http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
// If you add this line of tags to the page

// stay IE in :
document.body.clientWidth ==> BODY Object width
document.body.clientHeight ==> BODY Object height
document.documentElement.clientWidth ==> The width of the visible area
document.documentElement.clientHeight ==> Height of visible area
// stay FireFox in :
document.body.clientWidth ==> BODY Object width
document.body.clientHeight ==> BODY Object height
document.documentElement.clientWidth ==> The width of the visible area
document.documentElement.clientHeight ==> Height of visible area
?
// stay Opera in :
document.body.clientWidth ==> The width of the visible area
document.body.clientHeight ==> Height of visible area
document.documentElement.clientWidth ==> Page object width ( namely BODY Object width plus Margin wide )
document.documentElement.clientHeight ==> Page object height ( namely BODY Object height plus Margin high )
// And if there's no definition W3C Standards for , be
//IE by :
document.documentElement.clientWidth ==> 0
document.documentElement.clientHeight ==> 0
//FireFox by :
document.documentElement.clientWidth ==> Page object width ( namely BODY Object width plus Margin wide )document.documentElement.clientHeight ==> Page object height ( namely BODY Object height plus Margin high )
//Opera by :
document.documentElement.clientWidth ==> Page object width ( namely BODY Object width plus Margin wide )document.documentElement.clientHeight ==> Page object height ( namely BODY Object height plus Margin high )

版权声明
本文为[Silence is emptiness]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/202012080953043635.html