javascript取得整张页面的大小
2006-10-17 15:49
232 查看
//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
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;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
这个函数返回一个长度为四的数组{页面宽,页面高,窗口宽,窗口高}
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
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;
}
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
这个函数返回一个长度为四的数组{页面宽,页面高,窗口宽,窗口高}
相关文章推荐
- 使用 javascript 函数 完美控制页面图片显示大小(第二版) By shawl.qiu
- JS垮浏览器取得页面视口的大小
- js取得当前url,javascript获取当前页面url值,js获取域名
- 用 Javascript 获取页面大小、窗口大小和滚动条位置
- Javascript 自适应iframe页面大小(有效)
- JavaScript 取得当前页面的URL网址参数
- 用 Javascript 获取页面大小、窗口大小和滚动条位置
- Javascript获取页面、屏幕尺寸大小参数
- JavaScript实现两个Table固定表头根据页面大小自行调整
- JavaScript获得页面区域大小的代码
- javascript获取页面、屏幕大小
- javascript控制页面大小介绍
- 用 Javascript 获取页面大小、窗口大小和滚动条位置
- js取得当前url,javascript获取当前页面url值,js获取域名
- Javascript 取得页面高度
- javascript打开制定窗口大小的页面
- js取得当前url,javascript获取当前页面url值,js获取域名
- javascript获取页面、屏幕大小
- 最近接触到的一些js调用window窗体的属性及通过JavaScript获取页面大小
- 浏览器客户端智能自动化:如何取得页面中JavaScript运行时动态生成的URL?