• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. Browser Feature Detection > 5.1. Detecting the Browser Brand

Detecting the Browser Brand

NN 2, IE 3

Problem

You want script execution to branch one way for Netscape Navigator users and another for Internet Explorer users.

Solution

Use the navigator.appName property to find out which brand the browser purports to be. The following statement sets global Boolean variables for browser brands:

var isNav = (navigator.appName =  = "Netscape");
var isIE = (navigator.appName =  = "Microsoft Internet Explorer");

Discussion

The navigator.appName property returns a string that the browser maker determines. Netscape Navigator and Mozilla always return the string “Netscape”, while Internet Explorer returns “Microsoft Internet Explorer”. These strings and the equivalency operator are case-sensitive.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint