Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does navigator.appCodeName return Mozilla?

The following JavaScript code returns "Mozilla" on all browsers. Why?

 <script type="text/javascript">  document.write("Browser CodeName: " + navigator.appCodeName);  </script> 
like image 335
Venkat Avatar asked May 06 '10 11:05

Venkat


People also ask

What is the purpose of Navigator appCodeName?

The Navigator appCodeName Property is used for returning the code name of the browser. It is a read-only property and generally, all modern browsers return “Mozilla”. Return values: Returns a string that represents the code name of the browser.

Why does Netscape Navigator appName?

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...

What is appCodeName in Javascript?

The appCodeName property returns browser code name.


2 Answers

Short answer: Because people thought that user agent detection (instead of feature (AKA object) detection) was a good idea, so browser vendors started lying in order to compensate.

Long answer: History of the browser user-agent string

like image 153
Quentin Avatar answered Sep 17 '22 12:09

Quentin


Many years ago, developers used browser detection to reject other browsers, usually favouring Netscape Navigator (precursor to Mozilla and Firefox, also codenamed Mozilla). They tested for the string 'Mozilla' in the user agent. Internet Explorer got angsty and decided to imitate Netscape so they could join in on the fun.

like image 23
Delan Azabani Avatar answered Sep 19 '22 12:09

Delan Azabani