隨筆-57  評論-117  文章-1  trackbacks-0

          做手機Web開發做瀏覽器兼容用到了,所以在網上找了些匯總下。

          alert($(window).height()); //瀏覽器當前窗口可視區域高度 
          alert($(document).height()); //瀏覽器當前窗口文檔的高度 
          alert($(document.body).height());//瀏覽器當前窗口文檔body的高度 
          alert($(document.body).outerHeight(true));//瀏覽器當前窗口文檔body的總高度 包括border padding margin 
          alert($(window).width()); //瀏覽器當前窗口可視區域寬度 
          alert($(document).width());//瀏覽器當前窗口文檔對象寬度 
          alert($(document.body).width());//瀏覽器當前窗口文檔body的高度 
          alert($(document.body).outerWidth(true));//瀏覽器當前窗口文檔body的總寬度 包括border padding margin 
           
          // 獲取頁面的高度、寬度
          function getPageSize() {
              var xScroll, yScroll;
              if (window.innerHeight && window.scrollMaxY) {
                  xScroll = window.innerWidth + window.scrollMaxX;
                  yScroll = window.innerHeight + window.scrollMaxY;
              } else {
                  if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac    
                      xScroll = document.body.scrollWidth;
                      yScroll = document.body.scrollHeight;
                  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari    
                      xScroll = document.body.offsetWidth;
                      yScroll = document.body.offsetHeight;
                  }
              }
              var windowWidth, windowHeight;
              if (self.innerHeight) { // all except Explorer    
                  if (document.documentElement.clientWidth) {
                      windowWidth = document.documentElement.clientWidth;
                  } else {
                      windowWidth = self.innerWidth;
                  }
                  windowHeight = self.innerHeight;
              } else {
                  if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode    
                      windowWidth = document.documentElement.clientWidth;
                      windowHeight = document.documentElement.clientHeight;
                  } else {
                      if (document.body) { // other Explorers    
                          windowWidth = document.body.clientWidth;
                          windowHeight = document.body.clientHeight;
                      }
                  }
              }       
              // for small pages with total height less then height of the viewport    
              if (yScroll < windowHeight) {
                  pageHeight = windowHeight;
              } else {
                  pageHeight = yScroll;
              }    
              // for small pages with total width less then width of the viewport    
              if (xScroll < windowWidth) {
                  pageWidth = xScroll;
              } else {
                  pageWidth = windowWidth;
              }
              arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
              return arrayPageSize;
          }
           
          // 滾動條
          document.body.scrollTop;
          $(document).scrollTop();


          作者:hoojo
          出處:
          blog:http://blog.csdn.net/IBM_hoojo
                   http://hoojo.cnblogs.com
          本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。


          版權所有,轉載請注明出處 本文出自:
          分享道版權所有,歡迎轉載,轉載請注明出處,謝謝
          posted on 2012-02-16 17:45 hoojo 閱讀(12524) 評論(0)  編輯  收藏 所屬分類: JavaScript 、jQuery
          主站蜘蛛池模板: 和静县| 新泰市| 勃利县| 淄博市| 乳山市| 满洲里市| 海兴县| 班玛县| 赞皇县| 忻州市| 寿光市| 虞城县| 沅江市| 三门峡市| 甘泉县| 边坝县| 新竹县| 临沧市| 宁南县| 丹巴县| 新野县| 佳木斯市| 临猗县| 易门县| 琼结县| 泰和县| 台南县| 蕉岭县| 交城县| 枣阳市| 康平县| 徐闻县| 读书| 县级市| 枣强县| 枣阳市| 渭南市| 维西| 临西县| 扬州市| 吉安县|