//获取网页可见区域宽高function getViewPortOffset() { ???if(window.innerWidth) { ???????return { ???????????w: window.innerWidth, ???????????h: window.innerHeight ???????} ???} else { ???????if(document.compatMode === "BackCompat") { ???????????//compatMode 用来确认是否关闭或开启了标准兼容模式 ???????????//BackCompat:标准兼容模式关闭。 ???????????//CSS1Compat:标准兼容模式开启。 ???????????return { ???????????????w: document.body.clientWidth, ???????????????h: document.body.clientHeight ???????????} ???????} else { ???????????return { ???????????????w: document.documentElement.clientWidth, ???????????????y: document.documentElement.clientHeight ???????????} ???????} ???}}
获取网页可见区域宽高(封装免邮)
原文地址:https://www.cnblogs.com/fearless427/p/9765649.html