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

JavascriptHtmlFirefoxDomBrowser

Javascript Problem Overview


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?

Javascript Solutions


Solution 1 - Javascript

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.

Solution 2 - Javascript

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.

Source here.

Solution 3 - Javascript

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://docs.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

Solution 4 - Javascript

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionC graphicsView Question on Stackoverflow
Solution 1 - JavascriptOnur YıldırımView Answer on Stackoverflow
Solution 2 - Javascriptuser1786283View Answer on Stackoverflow
Solution 3 - JavascriptmagikMakerView Answer on Stackoverflow
Solution 4 - JavascriptAdam R. TurnerView Answer on Stackoverflow