JQuery获取页面高度,页面宽度,窗口高度,窗口宽度


JQuery获取页面高度,页面宽度,窗口高度,窗口宽度
  1. function ___getPageSize() {   
  2.             var xScroll, yScroll;   
  3.             if (window.innerHeight && window.scrollMaxY) {     
  4.                 xScroll = window.innerWidth + window.scrollMaxX;   
  5.                 yScroll = window.innerHeight + window.scrollMaxY;   
  6.             } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac   
  7.                 xScroll = document.body.scrollWidth;   
  8.                 yScroll = document.body.scrollHeight;   
  9.             } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari   
  10.                 xScroll = document.body.offsetWidth;   
  11.                 yScroll = document.body.offsetHeight;   
  12.             }   
  13.             var windowWidth, windowHeight;   
  14.             if (self.innerHeight) { // all except Explorer   
  15.                 if(document.documentElement.clientWidth){   
  16.                     windowWidth = document.documentElement.clientWidth;    
  17.                 } else {   
  18.                     windowWidth = self.innerWidth;   
  19.                 }   
  20.                 windowHeight = self.innerHeight;   
  21.             } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode   
  22.                 windowWidth = document.documentElement.clientWidth;   
  23.                 windowHeight = document.documentElement.clientHeight;   
  24.             } else if (document.body) { // other Explorers   
  25.                 windowWidth = document.body.clientWidth;   
  26.                 windowHeight = document.body.clientHeight;   
  27.             }      
  28.             // for small pages with total height less then height of the viewport   
  29.             if(yScroll < windowHeight){   
  30.                 pageHeight = windowHeight;   
  31.             } else {    
  32.                 pageHeight = yScroll;   
  33.             }   
  34.             // for small pages with total width less then width of the viewport   
  35.             if(xScroll < windowWidth){      
  36.                 pageWidth = xScroll;           
  37.             } else {   
  38.                 pageWidth = windowWidth;   
  39.             }   
  40.             arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);   
  41.             return arrayPageSize;   
  42.         };  

相关内容