56

Why does navigator.appName return "Netscape" for Safari, Firefox and Chrome?

What do they have to do with the old browser Netscape? Could it be because of DOM0?

TRiG
  • 10,148
  • 7
  • 57
  • 107
C graphics
  • 7,308
  • 19
  • 83
  • 134
  • 11
    http://webaim.org/blog/user-agent-string-history/ Funny, but relevant. – Amadan Jan 29 '13 at 00:57
  • AFAIK it's because of very old compatibility issues, and it just stayed like that. – elclanrs Jan 29 '13 at 00:58
  • Also quoted from MDN: "Returns the name of the browser. The HTML5 specification also allows any browser to return "Netscape" here, for compatibility reasons." - https://developer.mozilla.org/en-US/docs/DOM/window.navigator.appName – istos Jan 29 '13 at 00:59

4 Answers4

49

Yes and that's for compatibility issues and not to be relied on.
MDN says: "This was originally part of DOM Level 0, but has been since included in the HTML5 spec."

See Mozilla documentation here.

BTW; that's why this cannot be used for browser detection. Browser detection is a BAD practice and you should always avoid it where possible. Do feature detection instead. But if anybody insists on this; they should use the userAgent property instead.

UPDATE 1: According to Compatibility Changes; IE11 now also returns "Netscape" for navigator.appName property, to reflect the HTML5 standard and to match behavior of other browsers. Also see changes in userAgent string here... More on feature detection here...

UPDATE 2: Microsoft Edge also returns "Netscape" for navigator.appName.

Onur Yıldırım
  • 32,327
  • 12
  • 84
  • 98
  • Here is some [additional documentation](https://developer.mozilla.org/en-US/docs/Web/API/window.navigator) about related fields. Note that many are marked, "Do not rely on this property to return the correct value," as many browsers return counter-intuitive results. – Steven Jul 08 '13 at 16:36
  • 1
    but do you ever thought that _sometimes_ we aren't looking for features, but just tracking? If I have a user base who mostly uses IE7-, why I will spend my time building features who the major part of my users will not even see anything? Same for the other browsers. Not always we're looking for the userAgent just because we want to hide/show features accordingly. – Joao Paulo Rabelo May 21 '14 at 16:31
  • 11
    Sometimes browser detection is absolutely required to make things work. The dogma is that it's BAD BAD BAD, but there are certainly many cases where you have no choice. – Joshua Jul 18 '14 at 23:21
  • 1
    Totally agree with @Joshua, there are times when browser detection are required as there isn't a specific feature to check for, such as if a third party plugin will work as expected. In these situations you need to isolate browsers based on version and not having easy ways to do that is a pain. jQuery removing .browser is annoying. I get the whole best practise stuff, but it's not helpful as an absolute. – andyface Jan 28 '15 at 16:05
  • D3 returning incorrect text sizes using getBBox() by as much as 13 pixels is also bad practice. Hence the reason to be forced to know the browser type so you can adjust. – RandallTo Aug 07 '15 at 20:02
9

Based on Johnny Stenback's post:

This was debated on the mozilla newsgroups ages ago and it was decided that navigator.appName should return 'Netscape' even in mozilla since if that were to be changed every page out on the web that uses some browser sniffing code (and that's a HUGE part of the current web) would need to recognize mozilla, and that just won't happen and there's no reason to do that either since mozilla == netscape == mozilla as far as content developers are conserned [sic].

Source here.

Michael M.
  • 10,486
  • 9
  • 18
  • 34
4

Starting in IE11, Explorer will now also return "Netscape" when calling navigator.appName;

Update Although this answer is rather outdated by now, here is the link for the statement above: https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/dev-guides/bg182625(v=vs.85)?redirectedfrom=MSDN#legacy-api-additions-changes-and-removals

magikMaker
  • 4,929
  • 1
  • 33
  • 25
0

One can just search the navigator.userAgent for browser detection for IE 11 now and look for its layout engine. In my experience, it works fairly well. See this post.

Adam R. Turner
  • 139
  • 1
  • 2
  • 14