Javascript window.Navigator returning wrong data?

Asked

Viewed 30 times

2

I’m studying Javascript, and I came across something strange, I put this command on 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.

1 answer

6


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

You can read more about it on MDN:

The Navigatorid.appCodeName Always Returns 'Mozilla', on any browser. This Property is Kept only for Compatibility purposes.

Translating freely is more or less what I wrote here.

Where does this value of Mozilla?

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

  • 1

    It would be nice to complement the answer with reading of this.

  • 2

    @jbueno added more info, thanks. I’ll reread it later and add more if it’s missing.

  • Very interesting, I didn’t know these things, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.