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 " ;
}

你可能感兴趣的:(js)