用于检测 Internet Explorer 的用户代理字符串中最可靠的部分是什么?
例如,使用 Internet Explorer 时版本令牌是否始终以 MSIE 开头?
MSIE 可以显示为其他浏览器的令牌吗?
谢谢。
http://msdn.microsoft.com/en -us/library/ms537503%28v=vs.85%29.aspx
For example, does the version token always start with MSIE using Internet Explorer?
Can MSIE show up as the token of another browser?
Thank You.
http://msdn.microsoft.com/en-us/library/ms537503%28v=vs.85%29.aspx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTP_USER_AGENT 字符串没有部分是可靠的。有些浏览器会伪装成其他浏览器;用户可以随时更改该字符串。
这不是你问题的一部分,但无论如何我都会继续我的闲聊。
尝试通过 HTTP_USER_AGENT 来识别用户代理的做法称为“浏览器嗅探”,人们普遍认为这是一件坏事。
他们说,更好的方法是测试 IE 的版本;并测试浏览器版本特定功能的存在。这里有关于浏览器检测的有趣且专家的讨论:
http://www.jibbering.com /faq/notes/detect-browser/
编辑 20110516:c /HTTP_REFERER/HTTP_USER_AGENT/ g 抱歉犯了这个愚蠢的错误。
There is no part of the HTTP_USER_AGENT string that is reliable. Some browsers masquerade as others; and users can change that string any old time.
This isn't part of your question, but I'll just go on with my spoutfest anyway.
The practice of trying to identify the user agent by its HTTP_USER_AGENT is called "browser sniffing," pretty widely agreed to be a Bad Thing.
The better way, they say, is to test for versions of IE; and to test for the presence of browser-version specific features. There's an interesting and expert discussion of browser detection here:
http://www.jibbering.com/faq/notes/detect-browser/
EDIT 20110516: c /HTTP_REFERER/HTTP_USER_AGENT/ g Sorry for that stupid mistake.