The following JavaScript code returns "Mozilla" on all browsers. Why?
<script type="text/javascript"> document.write("Browser CodeName: " + navigator.appCodeName); </script>
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.
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...
The appCodeName property returns browser code name.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With