js识别用户设备是移动端手机时跳转到手机网站

 

一、识别到用户的设备是手机等移动端设备时跳转到移动端网站

var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
    var browser = navigator.userAgent.toLowerCase();
    var isMobile = false;
    for (var i = 0; i < mobileAgent.length; i++) {
        if (browser.indexOf(mobileAgent[i]) != -1) {
            isMobile = true;
            location.href = 'http://m.sxuek.com';
            break;
        }
    }

 

posted @ 2018-08-24 17:20  考拉很OK  阅读(955)  评论(0编辑  收藏  举报