js判断是否移动设备浏览

Jquery 判断是否 移动设备 浏览

$(document).ready(function() { 
    var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i) ? true : false;
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i) ? true : false;
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i) ? true : false;
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
    }
};
    
           if (isMobile.any()) {
                window.location = "xx.html";
               //or  $('.main_header').hide();
            }
            else if (isMobile.Android() || isMobile.iOS_Phone()) {
                window.location = "aa.html";
            }
            else {
                window.location = "bb.html";
            }
});

 

posted @ 2016-02-18 15:38  江湖丶丿新进程  阅读(105)  评论(0)    收藏  举报