js获取浏览器高度宽度

function getDocumentWidth() {
    var w1 = window.innerWidth; // Width (in pixels) of the browser window viewport including, if rendered, the vertical scrollbar.
    var w2 = document.documentElement.clientWidth;
    var w3 = document.body.clientWidth;
    return Math.max(w1, w2, w3);
}

function getDocumentHeight() {
    var h1 = window.innerHeight; // Height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.
    var h2 = document.documentElement.clientHeight;
    var h3 = document.body.clientHeight;
    return Math.max(h1, h2, h3);
}

 

posted @ 2015-10-05 09:57  记忆的森林  阅读(224)  评论(0)    收藏  举报