美文网首页Web前端之路
微信在ios上旋转屏幕过程中的bug

微信在ios上旋转屏幕过程中的bug

作者: stois | 来源:发表于2016-02-22 14:22 被阅读771次

我希望识别屏幕改变之后的宽与高,即clientWidth和clientHeight,但在微信的ios版测出了bug。
正常来说,orientationchange和resize后,屏幕信息应该立即返回,但这里需要给微信一点时间...另外添加一个alert也见效。

var evt = "onorientationchange" in window ? "orientationchange" : "resize";
      
    window.addEventListener(evt, function() {
        console.log(evt);
        setTimeout( function(){
                    var width = document.documentElement.clientWidth;
                     var height =  document.documentElement.clientHeight;
            ...
            
        }  , 10 );
        
        
    }, false);

这种写法虽然不科学,但也可以用了。

相关文章

网友评论

    本文标题:微信在ios上旋转屏幕过程中的bug

    本文链接:https://www.haomeiwen.com/subject/rprpkttx.html