JavaScript Example #3
Checking a browser version
As you may remember, the "navigator" object has a several attributes to get browser information. As an example as to how to show this infor, see the code below
<html>
<body>
<script type="text/javascript"> function showInfo(){
alert("You are using " + navigator.appName +
" version " + navigator.appVersion);
}
</script>
<p>Browser Info Example. After pressing the button, you'll get an alert window with the browser infromation</p>
<input type=button onclick="showInfo()" value="Click me! />
</body>
</html>
If you are using Firefox, the alert box will tell you that your are using Netscape. The only way you can tell if you are using Firefox is to get use the following. I've used JavaScript so you'll see what it says about your browser. The code is used is
document.write("navigator.appCodeName = " + navigator.appCodeName + "<br />");
document.write("navigator.appMinorVersion = " + navigator.appMinorVersion + "<br />");
document.write("navigator.appName = " + navigator.appName + "<br />");
document.write("navigator.appVersion = " + navigator.appVersion + "<br />");
document.write("navigator.cpuClass = " + navigator.cpuClass + "<br />");
document.write("navigator.platform = " + navigator.platform + "<br />");
document.write("navigator.javaEnabled() = " + navigator.javaEnabled() + "<br />");
The output from the above code is shown below...
You can see how even though attributes exist in JavaScript, they aren't always defined...