---
title: "浏览器判断"
author: "nickys"
date: "2015-01-07T21:09:24Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2015-01-07T21:09:24Z"
id: 2173689
url: "https://nickys.iteye.com/blog/2173689"
---

var request = false; 
var btype=getInternet();  
function getInternet()    
{    
if(navigator.userAgent.indexOf("MSIE")>0) {    
              return "MSIE";       //IE浏览器  
}  
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){    
              return "Firefox";     //Firefox浏览器  
}  
if(isSafari=navigator.userAgent.indexOf("Safari")>0) {    
              return "Safari";      //Safan浏览器  
}  
if(isCamino=navigator.userAgent.indexOf("Camino")>0){    
              return "Camino";   //Camino浏览器  
}  
if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){    
              return "Gecko";    //Gecko浏览器  
}    
}   
try { 
  request = new XMLHttpRequest(); 
} catch (trymicrosoft) { 
  try { 
    request = new ActiveXObject("Msxml2.XMLHTTP");//支持microsoft 
  } catch (othermicrosoft) { 
    try { 
      request = new ActiveXObject("Microsoft.XMLHTTP");//支持非microsoft 
    } catch (failed) { 
      request = false;  
    }  
} 
} 

if(!request) 
  alert("Error!!游览器不安全,请选择较高版本游览器!");