JavaScript window.navigator returning wrong data?

2

I am studying JavaScript, and I came across something strange, I put this command in the Chrome console alert(navigator.appCodeName); , which returns the browser name, but always returns, "Mozilla" , instead of "Chrome" , I would like to know the reason.

    
asked by anonymous 09.10.2015 / 18:29

1 answer

6

This property is deprecated and its result is always the same in any browser. It is maintained in some browsers for compatibility issues.

You can read more about this at MDN:

  

The NavigatorID.appCodeName always returns 'Mozilla', on any browser. This property is kept for compatibility purposes only.

Translating freely is more or less what I wrote here.

Where does this Mozilla value come from?

Many years ago there were not as many browsers as there are today. Netscape was one of the first to be large and appeared in the continuation of Mosaic , and later the Mozilla (Mosaic + Godzilla). In those times the first way to distinguish different browsers was to join properties (like today still .userAgent ) and this is one of them. What's curious is that Microsoft has adopted the same second and this articles) by pretending to be a browser that it really was not. By this I meant that it was compatible with Netscape, but it invalidated the usefulness of properties like this and hence it was deprecated because it is useless.

    
09.10.2015 / 18:42