js文档视口高度函数

objwin=window;objBody=document.body;objDel=document.documentElement;   关于弹窗时候用到

function getPageHeight() { //文档高度 scrollMaxY 火狐Mozilla
var h = (objWin.innerHeight && objWin.scrollMaxY) ? (objWin.innerHeight + objWin.scrollMaxY) : (objBody.scrollHeight > objBody.offsetHeight ? objBody.scrollHeight : objBody.offsetHeight);
return Math.max(h, objDel.scrollHeight)
}

function getPageWidth() {
return (objWin.innerWidth && objWin.scrollMaxX) ? (objWin.innerWidth + objWin.scrollMaxX) : (Math.max(objBody.scrollWidth, objBody.offsetWidth))
}

function getWinHeight() { //可视化高度
return (objWin.innerHeight) ? objWin.innerHeight : (objDel && objDel.clientHeight) ? objDel.clientHeight : objBody.clientHeight
}

function getWinWidth() {
return (objWin.innerWidth) ? objWin.innerWidth : (objDel && objDel.clientWidth) ? objDel.clientWidth : objBody.clientWidth
}

function getMaxH() {
var a = getPageHeight(),
wh = getWinHeight();
return Math.max(a, wh)
}

function getMaxW() {
var a = getPageWidth(),
ww = getWinWidth();
return Math.max(a, ww)
}

posted on 2013-09-12 16:04  rainbow661314  阅读(984)  评论(0编辑  收藏  举报