js监听窗口变化及获取窗口大小

window.οnresize=function(){  
 $(window).width();  
}  

窗口大小:

    var offsetWid = document.documentElement.clientWidth;
    var offsetHei = document.documentElement.clientHeight;

    if (/(Android)/i.test(navigator.userAgent)){     // 判断是否为Android手机
        offsetWid = screen.width;
        offsetHei = screen.height;
    }else if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){  // 判断是否为苹果手机
        offsetWid=document.documentElement.clientWidth;
        offsetHei=document.documentElement.clientHeight;
    }



你可能感兴趣的:(JavaScript,h5)