2023用JavaScript如何找到网页浏览器的名称和版本?

 所属分类:web前端开发

 浏览:57次-  评论: 0次-  更新时间:2023-10-08
描述:更多教程资料进入php教程获得。 要查找网络浏览器的名称和版本,您需要尝试以下代码 -示例<html> <head> <title>B...
更多教程资料进入php教程获得。

用JavaScript如何找到网页浏览器的名称和版本?

要查找网络浏览器的名称和版本,您需要尝试以下代码 -

示例

<html>
   <head>
      <title>Browser Detection Example</title>
   </head>
   <body>
      <script>
         <!--
            var userAgent = navigator.userAgent;
            var opera = (userAgent.indexOf('Opera') != -1);
            var ie = (userAgent.indexOf('MSIE') != -1);
            var gecko = (userAgent.indexOf('Gecko') != -1);
            var netscape = (userAgent.indexOf('Mozilla') != -1);
            var version = navigator.appVersion;

            if (opera) {
               document.write("Opera based browser");
               // Keep your opera specific URL here.
            }
            else if (gecko) {
               document.write("Mozilla based browser");
               // Keep your gecko specific URL here.
            }
            else if (ie) {
               document.write("IE based browser");
               // Keep your IE specific URL here.
            }
            else if (netscape) {
               document.write("Netscape based browser");
               // Keep your Netscape specific URL here.
            } else {
               document.write("Unknown browser");
            }
            // You can include version to along with any above condition.
            document.write("<br /> Browser version info : " + version );
         //-->
      </script>
   </body>
</html>
 标签:
积分说明:注册即送10金币,每日签到可获得更多金币,成为VIP会员可免金币下载! 充值积分充值会员更多说明»

讨论这个素材(0)回答他人问题或分享使用心得奖励金币

〒_〒 居然一个评论都没有……

表情  文明上网,理性发言!