一些非 IE 浏览器在 IE6 浏览器检测中显示为 true
所以我正在运行 jQuery 1.3.2(是的,它很旧,现在我无法升级)。
问题是我正在尝试放弃对我们内部站点的 IE6 支持并升级浏览器。我有这个检查
if($.browser.msie && $.browser.version=="6.0") {
// do something...
}
,但在测试过程中(一些)Firefox 用户看到了 do some
条件,但不应该是这样。以下是我认为可能导致该问题的一些用户代理。
- UserAgent:Mozilla/5.0(Windows NT 6.1;WOW64)AppleWebKit/535.7(KHTML,如 Gecko)Chrome/16.0.912.75 Safari/535.7
- UserAgent:Mozilla/5.0(Windows;U;Windows NT 5.1;en-US;rv:1.9 .2.23) 壁虎/20110920 Firefox/3.6.23
- UserAgent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7(KHTML,如 Gecko) Chrome/16.0.912.75 Safari/535.7
- UserAgent:Mozilla/5.0(Windows;U;Windows NT 6.1;en-US;版本:1.9.2.25) 壁虎/20111212 Firefox/3.6.25
- UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
我还需要更多 IE6 验证吗?
注意:最终用户没有安装任何附加组件。我以为像 IE-Tabs 这样的东西可能会导致问题,但事实并非如此
更新:
下面的所有回复都引导我到此,仍在测试,但看起来不错。关于如何改进它有什么想法吗?
var ie6 = $.browser.msie && parseInt($.browser.version) === 6 && typeof window['XMLHttpRequest'] !== "object";
if(typeof document.body.style.maxHeight === "undefined" && ie6) {
alert('Your browser is IE6');
}
相关问题:
So I'm running jQuery 1.3.2 (yep it's old and right now I can't upgrade).
Problem is I'm trying to drop IE6 support for our internal site and upgrade the browser. I have this check
if($.browser.msie && $.browser.version=="6.0") {
// do something...
}
But during testing (some) Firefox users are seeing the do something
condition and should'nt be. Here are some of the User Agents that I think might be causing the issue.
- UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7
- UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.23) Gecko/20110920 Firefox/3.6.23
- UserAgent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7
- UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.25) Gecko/20111212 Firefox/3.6.25
- UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12
Is there more IE6 validation I need?
Note: The end user has no add-ons installed. I was thinking something like IE-Tabs could cause the issue but that's not the case
UPDATE:
All of the responses below lead me to this, still testing but it looks good. Any thoughs on how to improve it?
var ie6 = $.browser.msie && parseInt($.browser.version) === 6 && typeof window['XMLHttpRequest'] !== "object";
if(typeof document.body.style.maxHeight === "undefined" && ie6) {
alert('Your browser is IE6');
}
Related questions:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
不要使用浏览器检测。特征检测要好得多。如果您只想向 IE 6 用户显示消息或其他内容,我建议使用 条件注释< /a> 相反。
Don't use browser detection. Feature detection is much nicer. And if you want to display a message or something to only IE 6 users, I would recommend using conditional comments instead.
来自 jQuery 文档
或者,您可以使用:
From jQuery Documentation
Altenatively you can use:
感谢大家帮助我找到了我要找的东西,也许这可能对其他人有帮助
Thanks all to helped me find what I was looking for, maybe this might help others
你可以使用这个:
将仅针对 IE6。
http://www.unintentionallyblank.co.uk/2006/09/19/if-internet-explorer-then-do-something-else-a-how-to/
You can use this:
<!--[If IE 6]> Your code here <![endif]-->
will target IE6 only.http://www.unintentionallyblank.co.uk/2006/09/19/if-internet-explorer-then-do-something-else-a-how-to/
如果你想让一行脚本找到IE6及以下版本并且不能使用条件注释:
if('\v'==='v' && !window.XMLHttpRequest) {
// 做某事...
}
if you want a line of script to find IE6 and below and you can't use conditional comments:
if('\v'==='v' && !window.XMLHttpRequest) {
// do something...
}
您想要做的事情是什么需要知道浏览器是否是 IE6?让我们消除它。
What is the thing you are trying to do that requires knowing if the browser is IE6? Let's eliminate that.