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