JavaScript Browser Detection

JavaScript Browser Detection

Java Script browser detection is based on the “navigator” object, which could just be thought of as the browser.

Browser Properties

Java Script defines eight properties browsers can report:

Browser Properties Description
appCodeName Specifies the code name of the browser.
appName Specifies the name of the browser.
appVersion Specifies version information for the Navigator.
language Indicates the translation of the Navigator being used.
mimeTypes An array of all MIME types supported by the client.
platform Indicates the machine type for which the Navigator was compiled.
plugins An array of all plug-ins currently installed on the client.
userAgent Specifies the user-agent header.

Browser Detection.

It is very easy to detect browser through Java Script by using Nevigator Object.Java Script provides the facility to getting client (browser) details through Nevigator Object. Client name, Client version, codename and the platform used are available through the navigator object and its properties.
Navigator object Description
navigator.appName Gives the name of the browser (application Name)
navigator.appVersion Gives the browser version (application Version)
navigator.appCodeName Gives the browser codename (application CodeName)
navigator.platform Gives the platform on which the browser is running

Browser Detection Example:

<script type=”text/javascript”>
function GetVersion()
var name = navigator.appName
var vers = navigator.appVersion
var text =””
text += ‘

You are using: ‘
text += name +’ ‘+ vers
text += ‘</P>’