如何根据手机系统来判断浏览器URL跳转指定页面

浏览器.jpg

一、根据浏览器判断URL跳转

var browserOfMobile = {
    wapUrl: 'http://m.baidu.com',
    versions:function(){
        var u = navigator.userAgent;
        return {
            //mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/), //是否为移动终端
            mobile: u.match(/(iPhone|iPod|Android|ios|iPad)/i),
        };
    }()
}
if (browserOfMobile.versions.mobile && browserOfMobile.wapUrl != '') {
    location.href = browserOfMobile.wapUrl;
}

二、低版本IE判断

(function() {
    if(navigator.userAgent.indexOf('MSIE') != -1) {
        var ieBrowser = navigator.userAgent.split(';')[1];
        if(ieBrowser.indexOf('MSIE') != -1 && parseInt(($.trim(ieBrowser)).substr(5)) < 9.0) {
            window.location.href = 'browser_download.html';
        }
    }
}());

你可能感兴趣的:(如何根据手机系统来判断浏览器URL跳转指定页面)