所有流行的浏览器的用户代理字符串,甚至Internet Explorer的,都以Mozilla/开头。为什么会这样呢?


当前回答

这是一个漫长而悲伤的故事。

总而言之:

Mozilla browser gets released, with User-Agent Mozilla/1.0 (Win3.1). It is publicly renamed to Netscape, but in its User-Agent it keeps its original name . Internet Explorer is released. It spoofs Netscape by starting its User-Agent with Mozilla/ because web servers were routinely browser sniffing and serving pages with frames - a feature supported by both Netscape and IE, but not other browsers of the era - to Netscape only. Over time, Gecko, Konqueror, Opera, Safari and Chrome each decide to similarly spoof the User-Agent of some previous browser in order to manipulate browser-sniffing web pages into correctly understanding their browser's features. As part of this spoofing, all the browsers start their User-Agents with Mozilla/, like the browsers before them had done. Plenty of other nonsense also results, like modern Chrome's User-Agent simultaneously claiming to be Mozilla, Chrome, Safari, and 'like Gecko'.

其他回答

Mozilla/5.0是表示浏览器与Mozilla兼容的通用令牌,目前几乎所有浏览器都使用它。 更多详情请点击这里

原因是臭名昭著的浏览器大战。

简而言之,浏览器开始伪装成其他浏览器,因为一些网站根据浏览器的要求提供内容,他们也想要为其他浏览器提供内容。

令人惊讶的是,这个问题到今天还没有解决。既然userAgent由于遗留原因不能安全删除,为什么没有引入一些明确标识浏览器的新特性呢?是的,大多数时候你不需要浏览器检测,而是一个功能检测,但它也不是内置的JS !

正如@Jason所说,“说来话长”。总结一下这个故事“只是每个浏览器都假装是Mozilla”

在尝试了一切之后,我终于用到了:http://www.useragentstring.com/

您可以使用上述网站获得格式化的用户代理和操作系统。 他们有一个你可以直接使用的API…

这是一个漫长而悲伤的故事。

总而言之:

Mozilla browser gets released, with User-Agent Mozilla/1.0 (Win3.1). It is publicly renamed to Netscape, but in its User-Agent it keeps its original name . Internet Explorer is released. It spoofs Netscape by starting its User-Agent with Mozilla/ because web servers were routinely browser sniffing and serving pages with frames - a feature supported by both Netscape and IE, but not other browsers of the era - to Netscape only. Over time, Gecko, Konqueror, Opera, Safari and Chrome each decide to similarly spoof the User-Agent of some previous browser in order to manipulate browser-sniffing web pages into correctly understanding their browser's features. As part of this spoofing, all the browsers start their User-Agents with Mozilla/, like the browsers before them had done. Plenty of other nonsense also results, like modern Chrome's User-Agent simultaneously claiming to be Mozilla, Chrome, Safari, and 'like Gecko'.

因为这就是网景对自己的定位,而微软想要与那些能够检测网景并拒绝其他任何东西的网站合作。