美文网首页
js 移动端网页 判断横屏和竖屏

js 移动端网页 判断横屏和竖屏

作者: Hi小胡 | 来源:发表于2019-07-30 17:37 被阅读0次
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function () {
    if (window.orientation === 180 || window.orientation === 0) {
        //竖屏
    }
    if (window.orientation === 90 || window.orientation === -90) {
        //横屏
    }
}, false);

相关文章

网友评论

      本文标题:js 移动端网页 判断横屏和竖屏

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