Why does navigator.appCodeName return Mozilla?

后端 未结 4 1701
南笙
南笙 2020-12-05 17:30

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

 

        
相关标签:
4条回答
  • 2020-12-05 18:14

    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

    0 讨论(0)
  • 2020-12-05 18:24

    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.

    0 讨论(0)
  • 2020-12-05 18:24

    That navigator.appCodeName based on useragent string and In IE's useragent string, there is Mozilla 4.0 or something, so thats why its display Mozilla for both.

    0 讨论(0)
  • 2020-12-05 18:34

    This property is kept only for compatibility purposes.

    Please refer this page:

    https://developer.mozilla.org/en-US/docs/Web/API/NavigatorID/appCodeName http://www.w3schools.com/jsref/prop_nav_appcodename.asp

    https://webmasters.stackexchange.com/questions/20709/can-anyone-tell-me-why-does-chrome-tell-it-is-mozilla-and-safari-also

    0 讨论(0)
提交回复
热议问题