通用JS获取页面尺寸及窗口位置
function getClientSize() {
var doc = document.documentElement,
body = document.body;
return self.innerHeight ? [doc.clientWidth ? doc.clientWidth : self.innerWidth, self.innerHeight] : doc && doc.clientHeight ? [doc.clientWidth, doc.clientHeight] : [body.clientWidth, body.clientHeight];
}
function getPageSize() {
var doc = document.documentElement,
body = document.body,
scrollXY = window.innerHeight && window.scrollMaxY ?
[window.innerWidth + window.scrollMaxX, window.innerHeight + window.scrollMaxY] :
body.scrollHeight > body.offsetHeight ?
[body.scrollWidth, body.scrollHeight] :
[body.offsetWidth, body.offsetHeight],
windowXY = self.innerHeight ?
[doc.clientWidth ? doc.clientWidth : self.innerWidth, self.innerHeight] :
doc && doc.clientHeight ?
[doc.clientWidth, doc.clientHeight] :
[body.clientWidth, body.clientHeight];
return [scrollXY[0] < windowXY[0] ? scrollXY[0] : windowXY[0], scrollXY[1] < windowXY[1] ? windowXY[1] : scrollXY[1]];
}
function getScrollOffsets() {
var doc = document.documentElement,
body = document.body;
return window.pageYOffset ? [window.pageXOffset, window.pageYOffset] : doc && doc.scrollTop ? [doc.scrollLeft, doc.scrollTop] : [body.scrollLeft,body.scrollTop];
}
var doc = document.documentElement,
body = document.body;
return self.innerHeight ? [doc.clientWidth ? doc.clientWidth : self.innerWidth, self.innerHeight] : doc && doc.clientHeight ? [doc.clientWidth, doc.clientHeight] : [body.clientWidth, body.clientHeight];
}
function getPageSize() {
var doc = document.documentElement,
body = document.body,
scrollXY = window.innerHeight && window.scrollMaxY ?
[window.innerWidth + window.scrollMaxX, window.innerHeight + window.scrollMaxY] :
body.scrollHeight > body.offsetHeight ?
[body.scrollWidth, body.scrollHeight] :
[body.offsetWidth, body.offsetHeight],
windowXY = self.innerHeight ?
[doc.clientWidth ? doc.clientWidth : self.innerWidth, self.innerHeight] :
doc && doc.clientHeight ?
[doc.clientWidth, doc.clientHeight] :
[body.clientWidth, body.clientHeight];
return [scrollXY[0] < windowXY[0] ? scrollXY[0] : windowXY[0], scrollXY[1] < windowXY[1] ? windowXY[1] : scrollXY[1]];
}
function getScrollOffsets() {
var doc = document.documentElement,
body = document.body;
return window.pageYOffset ? [window.pageXOffset, window.pageYOffset] : doc && doc.scrollTop ? [doc.scrollLeft, doc.scrollTop] : [body.scrollLeft,body.scrollTop];
}