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

Javascript
让您的菜单不离网站
JavaScript去除空格的几种方法
TFDN图片播放器 不错自动播放
通过ifame指向的页面高度调整iframe的高度
解放web程序员的输入验证
让背景如此暗淡(一种弹出提示信息时页面背景色调改变的方法)
关于textarea的直观换行的一些研究材料
网页缓存文件批量改名工具
按钮里的字可以换行吗
许愿墙中用到的函数
自动更新作用
激活 ActiveX 控件
使用Javascript和DOM Interfaces来处理HTML
获取DOM对象的几种扩展及简写
splice slice区别
Array.slice()与Array.splice()的返回值类型
$$()函数应用实例
window.open的功能全解析
点击单元格后可编辑单元格内文本如何制作
用JavaScript脚本实现Web页面信息交互

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


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