獲取頁面高度,窗口高度,滾動條高度等參數(shù)值getPageSize,getPageScroll
更新時間:2006年09月22日 00:00:00 作者:
復制代碼 代碼如下:
function getPageScroll(){
var yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
yScroll = document.documentElement.scrollTop;
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
}
arrayPageScroll = new Array('',yScroll)
return arrayPageScroll;
}
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
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
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;
}
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
相關文章
JavaScript實現(xiàn)基于十進制的四舍五入實例
這篇文章主要介紹了JavaScript實現(xiàn)基于十進制的四舍五入的方法,實例分析了javascript針對數(shù)值判斷與相關運算技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-07-07淺析AMD CMD CommonJS規(guī)范--javascript模塊化加載學習心得總結
下面小編就為大家分享一篇淺析AMD CMD CommonJS規(guī)范--javascript模塊化加載學習心得總結。小編覺得寫的非常不錯,需要的朋友可以過來參考一下2016-03-03JavaScript 用cloneNode方法克隆節(jié)點的代碼
很多時候我們需要通過HTML DOM 的方式,用JavaScript 動態(tài)生成很多相同的節(jié)點,包括其子節(jié)點2012-10-10