本文主要是介绍返回[页宽,页高,可见区宽,可见区高],希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
/*返回[页宽,页高,可见区宽,可见区高]
*/
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 {
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) {
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) {
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
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;
}
这篇关于返回[页宽,页高,可见区宽,可见区高]的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!