判断IE和360浏览器

var check = function(r) {
return r.test(navigator.userAgent.toLowerCase());
};
var statics = {
/**
* 是否为webkit内核的浏览器
*/
isWebkit: function() {
return check(/webkit/);
},
/**
* 是否为火狐浏览器
*/
isFirefox: function() {
return check(/firefox/);
},
/**
* 是否为谷歌浏览器
*/
isChrome: function() {
return !statics.isOpera() && check(/chrome/);
},
/**
* 是否为Opera浏览器
*/
isOpera: function() {
return check(/opr/);
},
/**
* 检测是否为Safari浏览器
*/
isSafari: function() {
// google chrome浏览器中也包含了safari
return !statics.isChrome() && !statics.isOpera() && check(/safari/);
}
};

//判断是否是ie浏览器和360浏览器
(function(window) {
var ms_ie = false;
var ua = window.navigator.userAgent.toLowerCase();
// alert(ua);
// var ua = navigator.userAgent.toLowerCase();
var old_ie = ua.indexOf('MSIE');
var new_ie = ua.indexOf('trident/');
var is360 = false;
var append = document.getElementById("append");
if((old_ie > -1) || (new_ie > -1)) {
ms_ie = true;
}
// alert(old_ie> -1);
// alert(new_ie > -1);
if(window.navigator.appName.indexOf("Microsoft") != -1) {
me_ie = true;
}

if((window.navigator.mimeTypes[40] || !window.navigator.mimeTypes.length)) {
is360 = true;
}

if(ms_ie) {
document.documentElement.className += "ie";
append.style.display = "block";
} else {
append.style.display = "none";
}

})(window);

posted @ 2017-02-27 17:10  被折叠的记忆  阅读(751)  评论(0编辑  收藏  举报