美文网首页FEtool
H5 使用JS禁止横竖屏切换、强制横竖屏

H5 使用JS禁止横竖屏切换、强制横竖屏

作者: 记忆是条狗 | 来源:发表于2017-03-09 10:56 被阅读0次

ipad: 90 或 -90 横屏
ipad: 0 或180 竖屏
Andriod:0 或180 横屏
Andriod: 90 或 -90 竖屏
js判断屏幕横竖屏:

    function orient() {
        //alert('gete');
        if (window.orientation == 0 || window.orientation == 180) {
            $("body").attr("class", "portrait");
            orientation = 'portrait';
            return false;
        }
        else if (window.orientation == 90 || window.orientation == -90) {
            $("body").attr("class", "landscape");
            orientation = 'landscape';
   
            return false;
        }
    }
    $(function(){
        orient();
    });
   
    $(window).bind( 'orientationchange', function(e){
        orient();
    });

相关文章

网友评论

    本文标题:H5 使用JS禁止横竖屏切换、强制横竖屏

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