当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 获取页面高度,窗口高度,滚动条高度等参数值getPageSize,getPageScroll

Javascript
快速判断某个值是否在select中的方法
js-穷举法 (y0h)
彪哥1.1(智能表格)提供下载
prototype 1.5 & scriptaculous 1.6.1 学习笔记
IE中jscript/javascript的条件编译
prototype class详解
Javascript 事件捕获的备忘(setCapture,captureEvents)
showModelessDialog()使用详解
Mozilla中显示textarea中选择的文字
加入收藏夹代码(兼容 gecko)
b/s开发常用javaScript技术
一些有关检查数据的JS代码
Javascript 不能释放内存.
多附件上传组件演示
一个很Cool的JS菜单效果
打造个性化的Select(可编辑)
真正的连续滚动图片
js常用函数 不错
document.getElementById的一些细节
由浅到深了解JavaScript类

Javascript 中的 获取页面高度,窗口高度,滚动条高度等参数值getPageSize,getPageScroll


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 106 ::
收藏到网摘: n/a

复制代码 代码如下:

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;
}