获取页面高度,窗口高度,滚动条高度等参数值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;
}
相关文章
layui 数据表格 根据值(1=业务,2=机构)显示中文名称示例
今天小编就为大家分享一篇layui 数据表格 根据值(1=业务,2=机构)显示中文名称示例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2019-10-10
JavaScript中有关一个数组中最大值和最小值及它们的下表的输出的解决办法
这篇文章主要介绍了JavaScript中有关一个数组中最大值和最小值及它们的下表的输出的一种解决办法,本文还给大家介绍了js快速获取数组中最大值和最小值的方法,非常不错,需要的朋友可以参考下2016-07-07
js判断radiobuttonlist的选中值显示/隐藏其它模块的实现方法
下面小编就为大家带来一篇js判断radiobuttonlist的选中值显示/隐藏其它模块的实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧2016-08-08


最新评论