navigator Properties Object Properties Summary
Retrieves the platform and version of the browser.
HTML |
N/A |
Script |
[ sVersion = ] navigator.appVersion |
4.0 ( compatible; MSIE 5; Windows NT ) |
String returned by Microsoft® Internet Explorer® 5. |
4.0 ( compatible; MSIE 4.01; Windows NT ) |
String returned by Microsoft® Internet Explorer® 4.01. |
4.04 ( en ) ( WinNT;I;Nav ) |
String returned by Netscape Navigator® 4.04 when running on Microsoft® Windows NT®. |
sVersion |
String specifying platform and version information for the browser. |
The property is read-only with a default value specified by the browser.
The following script detects the current user's browser and displays its appName and appVersion attributes in an alert box.
<script language="JavaScript">
<!--
function getBrowser ( ) {
var browser = navigator.appName;
browser += "\n" + navigator.appVersion;
alert ( browser );
}
//-->
</script>
Show me
Often, this attribute is used with appName to check for a browser requirement in a script. In the following, a variable "isIE4" checks to see if the string returned by appName contains "Microsoft ..." and the appVersion is 4 or later; if not, the variable returns false. Other scripts can then refer to this variable as needed.
<script language="JavaScript">
var isIE4 = ( ( navigator.appName ==
'Microsoft Internet Explorer' ) &&
( parseInt ( navigator.appVersion ) >= 4 ) );
...
if ( isIE4 )
... code for IE4
else
... code for others
</script>
navigator
appCodeName, appMinorVersion, appName, userAgent