js获取浏览器高度 宽度

系统管理员 2022-04-18 03:38 394阅读 0赞

/**
*计算客户端高度
**/
function getWinHeight() {
if (window.innerHeight) {
return window.innerHeight;
}
if (document.compatMode === “CSS1Compat”) {
return window.document.documentElement.clientHeight;
}
return window.document.body.clientHeight;
};

/**
*计算客户端宽度
**/
function getWinWidth() {
if (window.innerWidth) {
return window.innerWidth;
}
if (document.compatMode === “CSS1Compat”) {
return window.document.documentElement.clientWidth;
}
return window.document.body.clientWidth;
};

发表评论

表情:
评论列表 (有 0 条评论,394人围观)

还没有评论,来说两句吧...

相关阅读