要查找网络浏览器的名称和版本,您需要尝试以下代码 -
示例<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>
以上就是用javascript如何找到网页浏览器的名称和版本?的详细内容。