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

Javascript
JQuery 学习笔记 选择器之四
JQuery 学习笔记 选择器之五
JQuery 学习笔记 选择器之六
JQuery CSS样式控制 学习笔记
用js模仿word格式刷功能实现代码 [推荐]
运用jquery实现table单双行不同显示并能单行选中
jqPlot jquery的页面图表绘制工具
jquery tools之tabs 选项卡/页签
jquery tools之tooltip
浅析Javascript原型继承 推荐
JQuery UI皮肤定制
实现lightBox时的样式与行为分离减少JS
JQuery 表格操作(交替显示、拖动表格行、选择行等)
javascript 进度条 实现代码
Javascript this指针
jquery imgareaselect 使用利用js与程序结合实现图片剪切
javascript 写的一个简单的timer
javascript 处理HTML元素必须避免使用的一种方法
Javascript 验证上传图片大小[客户端]
jQuery 隔行换色 支持键盘上下键,按Enter选定值

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 233 ::
收藏到网摘: 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;
}