JS 获取网页内容高度 和 网页可视高度 支持IE 6789 Firefox Chrome 【转】
function getClientHeight() { //可见高 var clientHeight=document.body.clientHeight;//其它浏览器默认值 if(navigator.userAgent.indexOf("MSIE 6.0")!=-1) { clientHeight=document.body.clientHeight; } else if(navigator.userAgent.indexOf("MSIE")!=-1) { //IE7 IE8 clientHeight=document.documentElement.offsetHeight } if(navigator.userAgent.indexOf("Chrome")!=-1) { clientHeight=document.body.scrollHeight; } if(navigator.userAgent.indexOf("Firefox")!=-1) { clientHeight=document.documentElement.scrollHeight; } return clientHeight; } //获得网页内容高度 function getContentHeight() { //可见高 var ContentHeight=document.body.scrollHeight;//其它浏览器默认值 if(navigator.userAgent.indexOf("Chrome")!=-1) { ContentHeight= document.body.clientHeight; } if(navigator.userAgent.indexOf("Firefox")!=-1) { ContentHeight=document.body.offsetHeight; } return ContentHeight; }