This article is mainly for JS to obtain a variety of browser window size of the method is introduced, the need for friends can come to the reference, hope to help everyone else
Common: JS get browser window size code as follows://Get window width if (window.innerwidth) Winwidth = window.innerwidth; else if ( document.body) && (document.body.clientWidth)) Winwidth = document.body.clientwidth; //Get window height if (window.innerheight) Winheight = window.innerheight; else if ((document.body) && (document . Body.clientheight)) Winheight = document.body.clientheight; //Check the body inside the document to get the window size if ( Document.documentelement && document.documentElement.clientHeight && Document.documentElement.clientWidth) { winheight = document.documentelement.clientheight; Winwidth = document.documentelement.clientwidth; } Details: About getting various browser visible window sizes: <script> function GetInfo () { var s = "; s =" Web page visible area wide: "document.body.clientwidth; s =" page visible area High: "Docume nt.body.clientheight; s = "Web page visible area wide:" Document.body.offsetWidth (including Edge and scroll bar width); &nbSp s = "Web page visible Area High:" Document.body.offsetHeight (including edge width) "; s =" page body Full text width: "document.body.scrollwidth; s =" page body full Wengau: "document.body.scrollheight; s =" The Web page is rolled high (FF): "document.body.scrolltop; s =" The Web page is rolled high (ie): "Document.do cumentelement.scrolltop; s = "Web page is rolled away left:" document.body.scrollleft; s = "Web page body part:" window.screentop; s = Page body section left: "window.screenleft; s =" High screen resolution: "window.screen.height; s =" wide screen resolution: Window.screen.width;&nbs P s = "Screen available workspace height:" window.screen.availheight; s = "screen available working area width:" window.screen.availWidth; s = "Your screen settings are" window.screen.colorDepth "bit color"; s = "Your screen settings" Window.screen.deviceXDPI "pixel/inch"; //al ERT (s); } getInfo (); </script> in my local test: in IE, FireFox, opera can use document.body.clientwidth document.body.clientheight can be obtained, very simple, very convenient. In the company project: Opera still uses document.body.clientwidth Document.body.clientHeight But IE and Firefox use document.documentelement.clientwidth document.documentelement.clientheight It was the standard of the consortium. <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> If you add this line of markup to the page in IE: document.body.clientWidth ==> body Object width Document.body.clientHeight ==> Body Object height document.documentElement.clientWidth ==> visible area width Document.documentElement.clientHeight ==> Visible Area height : document.body.clientWidth ==> in Firefox Body Object width document.body.clientHeight ==> 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 ==> Page Object height (that is, the body object height plus margin height) And if there is no standard for the web, then IE is: Document.documentElement.clientWidth ==> 0 document.documentElement.clientHeight ==> 0 Firefox for: Document.documentElement.clientWidth ==> Page object width (that is, the body object width plus margin width) document.documentElement.clientHeight ==> Page Object height (that is, the body object height plus margin high) Opera is: document.documentElement.clientWidth ==> Page object width (that is, the body object width plus margin width) document.documentElement.clientHeight ==> Page Object height (that is, the body object height plus margin high)