You can use Outerwidth,outerheight to get the size of the browser in JavaScript. Use Innerwidth,innerheight to get the size of the window (except for the browser's border portion). For IE6 and previous versions, distinguish between standard mode and promiscuous mode. Standard mode uses document.documentelement.clientwidth,document.documentelement.clientheight promiscuous mode to use Document.body of Clientwidth,clientheight.
Copy Code code as follows:
(function () {
var pagewidth = window.innerwidth;
var pageheight = window.innerheight;
var broswerwidth = window.outerwidth;
var broswerheight = window.outerheight;
Alert (PageWidth + "" + pageheight);
Alert (Broswerwidth + "" + broswerheight);
if (typeof pagewidth!= "number") {
if (Document.compatmode = = "Css1compat") {//the standard mode
PageWidth = Document.documentElement.clientWidth;
PageHeight = Document.documentElement.clientHeight;
} else {
PageWidth = Document.body.clientWidth;
PageHeight = Document.body.clientHeight;
}
}
})();
Get the position of the window: Ie,chrome,safari, use screenleft,screentop to get the window's position from the left side of the screen and the top of the screen. Firefox does not support this property, Firefox uses Screenxp,screeny to achieve the same effect.
Copy Code code as follows:
(function Btnfun () {
var leftpos = (typeof Window.screenleft = "number")? Window.screenleft:
Window.screenx;
var toppos = (typeof window.screentop = "number")? Window.screentop:
Window.screeny;
Alert (LeftPos + "" + Toppos);
Alert (window.screenleft+ "" +window.screentop);
})();