Home>

In JavaScript, you can use outerwidth and outerheight to get the size of the browser.Use innerwidth, innerheight to get the size of the window (excluding the browser border). For ie6 and earlier,To distinguish between standard mode,Still promiscuous mode.Standard mode uses document.documentelement.clientwidth, document.documentelement.clientheight;promiscuous mode uses clientwidth, clientheight of document.body.

(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 position of the window from the left and top of the screen.And firefox does not support this property,firefox uses screenxp, screeny to achieve the same effect.

(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);
 }) ();
  • Previous Summary of methods for creating custom objects in Javascript
  • Next Java Concurrency Programming Example (1): Thread Creation and Execution
  • Trends