//IE 8 及更早 IE 版本不支持innerWidth和innerHeight这两个属性
function getViewportOffset() {
//各大主流浏览器
if (window.innerWidth !== undefined) {
return {
w: window.innerWidth,
h: window.innerHeight
}
} else {
// ie8及其以下
if (document.compatMode === "BackCompat") {
// 怪异模式
return {
w: document.body.clientWidth,
h: document.body.clientHeight
}
} else {
// 标准模式
return {
w: document.documentElement.clientWidth,
h: document.documentElement.clientHeight
}
}
}
}
js 获得窗口的高度与宽度
最新推荐文章于 2024-05-04 14:55:11 发布