Getting the width/height of the entire browser in IE?

后端 未结 5 1092
遇见更好的自我
遇见更好的自我 2020-12-03 16:25

Does anybody here know what the Javascript call is to get the width/height of the entire browser window (including nav, menu, etc?)

I know there is outerWidth<

5条回答
  •  情书的邮戳
    2020-12-03 16:41

    It's a variation of DreadPirateShawn's answer. Tested on IE7 and Chrome8. Originally appearing on Experts Exchange.

    function getWindowSize() {
        var wW, wH;
        if (window.outerWidth) {
            wW = window.outerWidth;
            wH = window.outerHeight;
        } else {
            var cW = document.body.offsetWidth;
            var cH = document.body.offsetHeight;
            window.resizeTo(500,500);
            var barsW = 500 - document.body.offsetWidth;
            var barsH = 500 - document.body.offsetHeight;
            wW = barsW + cW;
            wH = barsH + cH;
            window.resizeTo(wW,wH);
        }
        return { width: wW, height: wH };
    }
    

提交回复
热议问题