兼容方式js判断浏览器

1、兼容方式js
通过js判断浏览器跳转到特定网页

浏览设备跳转function goToUrl() {
var ua = navigator.userAgent.toLowerCase(),
     version = parseFloat($.browser.version),
     bType = getBrowserType(),
     compatibles = getIEVersion();

if(
ua.match(/ipad/i) == "ipad"
|| ua.match(/iphone os/i) == "iphone os"
|| ua.match(/midp/i) == "midp"
|| ua.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"
|| ua.match(/ucweb/i) == "ucweb"
|| ua.match(/android/i) == "android"
|| ua.match(/windows ce/i) == "windows ce"
|| ua.match(/windows mobile/i) == "windows mobile"
|| ($.browser.msie && (compatibles <= 8 || version <= 8 || bType == 'msie'))
|| $.browser.mozilla
|| ($.browser.opera && version <= 10.5)
|| $.browser.operamini
){
          window.location.href = 'index.html';
}else{
          $(document).mousedown(function() {
               return false;
          });
}
}

判断IE,跳转到特定网页

function isIE(){
     if(!!window.ActiveXOBject||"window.ActiveXOBject"in window){
          return true;
     }  else{
          reurn false
     }
}
function IEVersion() {
    var ua = navigator.userAgent;
    var reg = /Trident\/(\d+\.\d+)/;
    reg = reg.exec(ua);
    if (reg && reg[1]) {
        return +reg[1] + 4;
    }
    reg = /MSIE\s*(\d+\.\d+)/;
    reg = reg.exec(ua);
    if (reg && reg[1]) {
        return +reg[1];
    }
    return -1;
}

3、火狐跳转

if (navigator.userAgent.indexOf("Firefox")>0) {window.location.href = "./index_static.html"+location.search;};

4、IPAD跳转

if (/iPad/i.test(navigator.userAgent)) {window.location.href = "./ipad/index.html";};

你可能感兴趣的:(兼容方式js判断浏览器)