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

Javascript
总结一些js自定义的函数
与ClientWidth有关的一点资料
对联广告 flash版
连接文字不停变色
一条一条新闻向上的滚动 不错
Ctrl + Enter提交前检测的代码
对联广告 可关闭
一些很实用且必用的小脚本代码
巧妙破除网页右键禁用的十大绝招
实用javaScript技术-屏蔽类
静态的动态续篇之来点XML
显示行号的文本输入框
仿DVBBS下拉菜单效果 修正无错
移到这里,就会自动点击
让iframe框架网页在任何浏览器下自动伸缩
[原创]用srcElement实现添加效果
Javascript客户端脚本的设计和应用
解决 FireFox 下[使用event很麻烦] 的问题.
打字效果
简单的防盗链功能代码(iframe)

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


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