JavaScript has at its disposal a Navigator object that can be used to gain information about the browser that a web page visitor is using. This was highly beneficial in the past when there were more browsers that couldn’t run JavaScript. A separate version of the page could be set to run, depending on what browser the site visitor was using. It could also be used to tell visitors that there browser is too old to run a set of scripts that the website uses.
You can find out your browser’s information by referring to the Navigator object in your variable assignments.
<html>
<body>
<script type= “type/javascript”>
var browser=navigator.appName; //Tells you the name of your browser
var version=navigator.appVersion;//Tells you the version.
</script>
</body>
</html>
On an odd note, all versions of Internet Explorer 4.0 and above list 4 as their version number. The Navigator object can also be used to show the CPU and platform type of your system, the language setting of your system and browser, if cookies are enabled, and your minor version and User Agent. You can use the following code to display the attributes I mentioned.
function showAll()
{
var browser = navigator;
document.write("CodeName=" + browser.appCodeName);
document.write("MinorVersion=" + browser.appMinorVersion);
document.write("Name=" + browser.appName);
document.write("Version=" + browser.appVersion);
document.write("CookieEnabled=" + browser.cookieEnabled);
document.write("CPUClass=" + browser.cpuClass);
document.write("OnLine=" + browser.onLine);
document.write("Platform=" + browser.platform);
document.write("UA=" + browser.userAgent);
document.write("BrowserLanguage=" + browser.browserLanguage);
document.write("SystemLanguage=" + browser.systemLanguage);
document.write("UserLanguage=" + browser.userLanguage);
}
<input type="button" onclick="showAll()" value="Show Browser Details" />