原生js封装获取可视窗口的宽高(兼容所有浏览器,包括低版本IE)

var LY = {
//封装可视窗口的宽高
getViewportOffset : function(){
if(window.innerWidth){
return {
w : window.innerWidth,
h : window.innerHeight
}
}else{
if(document.compatMode == "BackCompat"){
return {
w : document.body.clientWidth,
h : document.body.clientHeight,
}
}else{
return {
w : document.documentElement.clientWidth,
h : document.documentElement.clientHeight
}
}
}

},

}

猜你喜欢

转载自blog.csdn.net/baidu_38027860/article/details/80064004