<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
let str = navigator.userAgent.toLowerCase();
console.log(str);
if (str.search("firefox") >= 0) {
alert("当前浏览器是火狐。");
} else if (str.search("trident") >= 0) {
alert("当前浏览器是IE。")
} else if (str.search("safari") >= 0) {
if (str.search("chrome") >= 0) {
alert("当前浏览器是谷歌。")
} else if (str.search("opr") >= 0) {
alert("当前浏览器是欧朋。")
} else {
alert("当前浏览器是苹果。")
}
} else {
alert("其他浏览器。")
}
</script>
</body>
</html>