转载 js判断浏览器
$scope.identifyBrowser= function () {
var userAgent =
navigator.userAgent,
rMsie =
/(msie\s|trident.*rv:)([\w.]+)/,
rFirefox =
/(firefox)\/([\w.]+)/,
rOpera =
/(opera).+version\/([\w.]+)/,
rChrome =
/(chrome)\/([\w.]+)/,
rSafari =
/version\/([\w.]+).*(safari)/;
var browser;
var
version;
var ua = userAgent.toLowerCase();
function uaMatch(ua) {
var match =
rMsie.exec(ua);
if (match != null) {
return { browser: "IE", version: match[2] || "0" };
}
var match = rFirefox.exec(ua);
if (match != null)
{
return { browser: match[1] || "", version: match[2] ||
"0" };
}
var match = rOpera.exec(ua);
if (match != null) {
return { browser:
match[1] || "", version: match[2] || "0" };
}
var match = rChrome.exec(ua);
if (match != null) {
return { browser: match[1] || "", version: match[2] || "0" };
}
var match = rSafari.exec(ua);
if (match != null) {
return { browser: match[2] ||
"", version: match[1] || "0" };
}
if
(match != null) {
return { browser: "", version: "0"
};
}
}
var browserMatch =
uaMatch(userAgent.toLowerCase());
if (browserMatch.browser) {
browser = browserMatch.browser;
version =
browserMatch.version;
}
return {
"browser": browser ,
"version": version
};
}
//判断当前页面时否在在IE浏览器下运行
$scope.joinConf= function () {
var temp = $scope.identifyBrowser();
if (temp.browser == "IE")
{
if (!$scope.initActivxObj()) {
}
} else {
alert("请选用IE浏览器!");
}
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。