1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title></title>
6 </head>
7 <body>
8
9 </body>
10
11 <script type="text/javascript">
12 // 获取到一行字符串,它是网页进行 http 请求时候,用户代理的头部信息
13 // navigator.userAgent
14 console.log(navigator.userAgent);
15
16 if(navigator.userAgent.indexOf("Chrome") != -1){
17 console.log("当前使用的是 chome 浏览器")
18 }else if(navigator.userAgent.indexOf("Safari") != -1){
19 console.log("当前使用的是 safari 浏览器");
20 }else if(navigator.userAgent.indexOf("Firefox") != -1){
21 console.log("当前使用的是 Firefox 浏览器");
22 }
23 </script>
24 </html>