navigator Properties Object Properties Summary
Retrieves the name of the browser.
HTML |
N/A |
Script |
[ sAppName = ] navigator.appName |
Microsoft Internet Explorer |
String returned by Microsoft® Internet Explorer. |
Netscape |
String returned by Netscape Navigator. |
sAppName |
String specifying the browser's name. |
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, appVersion, userAgent