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

要查找网络涉猎器的名称以及版原,你须要测验考试下列代码 -

事例

<html>
   <head>
      <title>Browser Detection Example</title>
   </head>
   <body>
      <script>
         <!--
            var userAgent = navigator.userAgent;
            var opera = (userAgent.indexOf(&#39;Opera&#39;) != -1);
            var ie = (userAgent.indexOf(&#39;MSIE&#39;) != -1);
            var gecko = (userAgent.indexOf(&#39;Gecko&#39;) != -1);
            var netscape = (userAgent.indexOf(&#39;Mozilla&#39;) != -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>
登录后复造

以上等于用JavaScript怎样找到网页涉猎器的名称以及版原?的具体形式,更多请存眷萤水红IT仄台此外相闭文章!

点赞(29) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部