獲取頁面高度,窗口高度,滾動條高度等參數(shù)值getPageSize,getPageScroll
更新時間:2006年09月22日 00:00:00 作者:
復(fù)制代碼 代碼如下:
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;
}
相關(guān)文章
JavaScript實現(xiàn)基于十進制的四舍五入實例
這篇文章主要介紹了JavaScript實現(xiàn)基于十進制的四舍五入的方法,實例分析了javascript針對數(shù)值判斷與相關(guān)運算技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-07-07JS自調(diào)用匿名函數(shù)具體實現(xiàn)
定義一個函數(shù)用做臨時的命名空間,在這個命名空間內(nèi)定義的變量都不會污染到全局命名空間,需要的朋友可以參考下2014-02-02淺析AMD CMD CommonJS規(guī)范--javascript模塊化加載學(xué)習(xí)心得總結(jié)
下面小編就為大家分享一篇淺析AMD CMD CommonJS規(guī)范--javascript模塊化加載學(xué)習(xí)心得總結(jié)。小編覺得寫的非常不錯,需要的朋友可以過來參考一下2016-03-03JavaScript 用cloneNode方法克隆節(jié)點的代碼
很多時候我們需要通過HTML DOM 的方式,用JavaScript 動態(tài)生成很多相同的節(jié)點,包括其子節(jié)點2012-10-10JavaScript學(xué)習(xí)筆記之惰性函數(shù)示例詳解
函數(shù)是js世界的一等公民,js的動態(tài)性、易變性在函數(shù)的應(yīng)用上,體現(xiàn)的淋漓盡致。下面這篇文章主要給大家介紹了關(guān)于JavaScript學(xué)習(xí)筆記之惰性函數(shù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細,需要的朋友可以參考下。2017-08-08javascript 面向?qū)ο髮崙?zhàn)思想分享
萬物皆對象,所以,任何事物都是有特征(屬性)和動作(方法)的,一般拿到一份需求分檔,或者你瀏覽一個網(wǎng)頁看到一個畫面的時候,腦子里就要有提煉出來的屬性和方法的能力,那你才是合格的2017-09-09