通过window.screen.availHeight可以获取,但是当浏览器不是最大化的时候,如何获取可用区域的高度。

解决方案 »

  1.   

    function getScreenSize()
    {
        var theWidth,theHeight;
        if (window.innerWidth) 
        { 
        theWidth = window.innerWidth 
        theHeight = window.innerHeight 
        } 
        else if (document.compatMode=='CSS1Compat') 
        { 
        theWidth = document.documentElement.clientWidth 
        theHeight = document.documentElement.clientHeight 
        } 
        else if (document.body) 
        { 
        theWidth = document.body.clientWidth 
        theHeight = document.body.clientHeight 
        } 
        var result = [theWidth,theHeight];
        return result;
    }var w = getScreenSize[0]//宽
    var h = getScreenSize[1]//高