当前位置 : 主页 > 网络编程 > JavaScript >

判断是否为手机端

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt function toLive() { var ua = navigator.userAgent; var ipad = ua.match(/(iPad).*OS\s([\d_]+)/), isIphone = !ipad ua.match(/(iPhone\sOS)\s([\d_]+)/), isAndroid = ua.match(/(Android)\s+([\d.]+)/), isMobile = isIphone || isAndroid
gistfile1.txt
function toLive() {
            var ua = navigator.userAgent;
            var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
                isIphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
                isAndroid = ua.match(/(Android)\s+([\d.]+)/),
                isMobile = isIphone || isAndroid;
            if (isMobile) {
                window.open('http://ihjrm.com/live/mroom.aspx?lcid=7586');
            } else {
                window.open('http://ihjrm.com/live/room2.aspx?lcid=7586');
            }
        }
网友评论