navigator 浏览器对象 反映了当前使用的浏览器的资料。
属性
<html> <head> <title>navigator浏览器对象用法</title> </head> <body> <script type="text/javascript"> document.write("appCodeName:" + navigator.appCodeName + "<br>"); //返回浏览器的“码名”(?),流行的 IE 和 NN 都返回 'Mozilla' document.write("appName:" + navigator.appName + "<br>"); //返回浏览器名。IE 返回 'Microsoft Internet Explorer',NN 返回 'Netscape' document.write("appVersion:" + navigator.appVersion + "<br>"); //返回浏览器版本,包括了大版本号、小版本号、语言、操作平台等信息。 document.write("platform: " + navigator.platform + "<br>"); //返回浏览器的操作平台,对于 Windows 9x 上的浏览器,返回 'Win32'(大小写可能有差异) document.write("userAgent:" + navigator.userAgent + "<br>"); //返回以上全部信息。例如,IE5.01 返回 'Mozilla/4.0 (compatible; MSIE 5.01; Windows 98) var j = navigator.javaEnabled() if (j = true) { document.write("当前浏览器允许运行Java"); } else if (j = false) { document.write("当前浏览器不允许运行Java"); } //返回一个布尔值,代表当前浏览器允许不允许 Java。 </script> </body> </html>