Native js encapsulation to get the width and height of the visible window (compatible with all browsers, including lower versions of 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
}
}
}

},

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324777959&siteId=291194637