获得客户区box宽高的兼容写法:
function getViewport() {
//ie7之前的兼容写法
if (document.compatMode == 'BackCompat') {
return {
width: document.body.clientWidth,
height: document.body.clientHeight
}
}
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight
}
}
console.log(getViewport());