Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 227
C graphics Avatar asked Jan 29 '13 00:01

C graphics


People also ask

Why is navigator appName Netscape?

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.

What is navigator appName in JavaScript?

It is used for returning the name of the browser. It is a read-only property and the values returned by it varies from browsers to browsers. it returns a string which represents the name of the browser.

What is navigator userAgent in JavaScript?

The Navigator userAgent property is used for returning the user-agent header's value sent to the server by the browser. It returns a string representing values such as the name, version, and platform of the browser.


1 Answers

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.

like image 126
Onur Yıldırım Avatar answered Sep 20 '22 14:09

Onur Yıldırım