JS获取当前页面的高度

var Client_Scrjs = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;

宽度如下:

function GetBrowserW() {
var winWidth = 0;
if (window.innerWidth) winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth)) winWidth = document.body.clientWidth;
if (document.documentElement && document.documentElement.clientWidth) {
winWidth
= document.documentElement.clientWidth;
}
var a = document.getElementById("happy");
winWidth
= winWidth - 900;
if (winWidth <= 0) {
winWidth
= 2;
}
else {
winWidth
= (winWidth / 2) + 5
}

a.style.left
= winWidth + "px";
a.style.visibility
= "visible";
}
posted @ 2010-12-17 18:12  Devin Mao  阅读(2771)  评论(1编辑  收藏  举报