Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of window.navigator.appCodeName?

In all browsers I tested (IE, Firefox, Chrome, Safari, Opera, Yandex), window.navigator.appCodeName returns "Mozilla". I know the history of web browsers "hijacking" the user agent to fool pages into thinking that they are compatible with all other browsers, and I was content to live with appCodeName just being an extension of that principal, however, I read the standard, and it turns out that the standard itself says that this will be the hardcoded value "Mozilla". So all these browsers are actually following the standards.

Why does this value exist? I assume it's reserved for future use, but what is the plan?

This question doesn't really explain it, because all it states is that it was because browsers hijacked it, which I already understand, but I'm moreso wondering what the past or future use was/is.

like image 743
LadyCailin Avatar asked Jun 15 '15 16:06

LadyCailin


2 Answers

From NavigatorID.appCodeName - Web API Interfaces:

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

Note: Do not rely on this property to return a real product name. All browsers return "Mozilla" as the value of this property.

This is similar to NavigatorID.product, which always returns the string 'Gecko'.

As Sebastian G. explains in his answer, it was used for user agent sniffing. This implies that at some point in time non-Mozilla browsers did not contain Mozilla in its UA string. Though I'm not sure how long the period of time was between Mozilla/Mozilla-based browsers had "Mozilla" in the UA string and the addition of "Mozilla" in non-Mozilla browsers.

I can't find any documentation on when the appCodeName property first became available in the navigator object (presumably before 2000, as it was referenced in 2000 as "ages ago").

This article might be of interest to you: Agent Strings in Popular Browsers

like image 83
rink.attendant.6 Avatar answered Nov 15 '22 03:11

rink.attendant.6


The war between browsers

It's a historical and compatibility purpose.

It all began when the first browsers appeared. Soon the battle of feature-implementation began (which isn't over after all). They wanted the developers to use their browser.

Because feature-detection wasn't a thing back then, browser-sniffing was the hot method to detect if a feature could be use. So developers sniffed around and implemented nice new features only for a specific browser. But then the other browser-vendor also implemented that feature, but the users didn't see it, because it wasn't a 'Mozilla' (for example).

The solution? Users of a non-Mozilla browser should also see that nice little feature and use the website as intended - so they all began to lie.


That's pretty much it in a nutshell. It's not reserved for future plans, but for past content access. And it's still like this, because the web is designed to last. So today you can visit a really old website and get all the information and features like in the old days.


Original Purpose

The property's purpose in first place was the representation of the internal code name of the browser (like 'Lollipop' for Android 5). Mozilla was one of the first ones to implement it - probably as an API for JS-Developer to explore or for their own scripts. And it was intended to represent the code name of each browser individually. But as mentioned, history took another path.

like image 43
Sebastian G. Marinescu Avatar answered Nov 15 '22 03:11

Sebastian G. Marinescu