---
title: "判断IE浏览器的N种方法"
author: "zerozone"
date: "2012-07-09T17:59:23Z"
tags: []
categories: ["Web前端"]
slug: "ie-n"
draft: false
lastmod: "2012-07-09T17:59:23Z"
id: 1583159
url: "https://zerozone.iteye.com/blog/1583159"
---

很多时候，我们需要知道浏览器类型，一般有两种方式：userAgent检测和特殊组件检测。

1) jquery

   uaMatch: function( ua ) {
	ua = ua.toLowerCase();

	var match = /(webkit)(+)/.exec( ua ) ||
		/(opera)(?:.*version)?(+)/.exec( ua ) ||
		/(msie) (+)/.exec( ua ) ||
	!/compatible/.test( ua ) && /(mozilla)(?:.*? rv:(+))?/.exec( ua ) || ;

	return { browser: match || "", version: match || "0" };
   }

2) SmartClient

isc.Browser.isOpera=(navigator.appName=="Opera"||navigator.userAgent.indexOf("Opera")!=-1);

isc.Browser.isIE=(navigator.appName=="Microsoft Internet Explorer"&&!isc.Browser.isOpera);

3) ueditor (baidu)

   browser = {
        /**
         * 检测浏览器是否为IE
         * @name baidu.editor.browser.ie
         * @property    检测浏览器是否为IE
         * @grammar     baidu.editor.browser.ie
         * @return     {Boolean}    返回是否为ie浏览器
         */
        ie : !!window.ActiveXObject,
        ...
  }