js获取页面窗口大小

function getWinSize(){

var winWidth =null;//宽度
var winHeight =null;//高度

if(window.innerWidth)
winWidth = window.innerWidth;
else if(document.body && document.body.clientWidth)
winWidth = document.body.clientWidth;


if(window.innerHeight)
winHeight = window.innerHeight;
else if(document.body && document.body.clientHeight)
winHeight = document.body.clientHeight;

//深入页面内部获取
if(document.documentElement && document.documentElement.clientWidth && document.documentElement.clientHeight){

winWidth = document.documentElement.clientWidth;
winHeight = document.documentElement.clientHeight;
}

return {width:winWidth,height:winHeight};
}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。