<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
</head>
<body>
<script>
detectBrowser();
function detectBrowser() {
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE浏览器
var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
var isChrome = userAgent.indexOf("Chrome") > -1;
var isEdge = userAgent.indexOf("Windows NT 6.1;") > -1 && userAgent.indexOf("Trident/7.0;") > -1;
var browserName = "";
if (isIE) {
//var IE5 = IE55 = IE6 = IE7 = IE8 = false;
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]);
browserName = "IE浏览器" + fIEVersion;
} else if (isFF) {
browserName = "火狐浏览器";
} else if (isChrome) {
browserName = "谷歌浏览器";
} else if (isEdge) {
browserName = "Edge浏览器";
}
output(browserName);
}
function output(browserName) {
document.write(browserName + "<br/>");
document.write("new Date():" + new Date());
}
</script>
<body>
</html>