判断IE浏览器的N种方法
很多时候,我们需要知道浏览器类型,一般有两种方式:userAgent检测和特殊组件检测。
-
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" }; }
-
SmartClient
isc.Browser.isOpera=(navigator.appName=="Opera"||navigator.userAgent.indexOf("Opera")!=-1);
isc.Browser.isIE=(navigator.appName=="Microsoft Internet Explorer"&&!isc.Browser.isOpera);
-
ueditor (baidu)
browser = { /** * 检测浏览器是否为IE * @name baidu.editor.browser.ie * @property 检测浏览器是否为IE * @grammar baidu.editor.browser.ie * @return {Boolean} 返回是否为ie浏览器 */ ie : !!window.ActiveXObject, ... }