Internet Explorer innerHeight

Sha*_*son 8 javascript internet-explorer

你怎么能在Internet Explorer中获得window.innerHeight.谢谢.

ken*_*bec 7

window.getWinSize= function(){
    if(window.innerWidth!= undefined){
        return [window.innerWidth, window.innerHeight];
    }
    else{
        var B= document.body, 
        D= document.documentElement;
        return [Math.max(D.clientWidth, B.clientWidth),
        Math.max(D.clientHeight, B.clientHeight)];
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 不应该是`Math.min()`而不是`Math.max()`?至少这似乎是你在ie7和ie8中想要的行为. (4认同)