使用功能检测而不是用户代理测试来测试 IE6
我将 html5boilerplate 与 Modernizr 库一起使用。我的应用程序是使用 jQuery 构建的。 Modernizr 和 jQuery 都内置了功能检测,但我的理解是 Modernizr 更完整。我计划使用 Modernizr 进行功能检测,除非有充分的理由使用 jQuery。
我的应用程序仅适用于更现代的浏览器(例如 IE7+、Firefox、Chrome、Safari 和较新的 Opera),但它在 IE6 中仍然可以正常工作。我想确保用户在使用 IE6 等较旧的浏览器时会看到一个很大的警告。如果他们尚未使用 Chrome 或其他一些兼容 HTML5 的浏览器,我还想显示升级到它们的“建议”。
我不想使用用户代理测试。
- 是否有我应该测试的特定功能列表,以确定用户是否使用 IE6?
- 是否有我应该测试的特定功能列表,以确定用户是否使用相当兼容的 HTML5 浏览器(Chrome、Safari、IE9 等)进行浏览
I'm using html5boilerplate with the Modernizr library. My application is built using jQuery. Both Modernizr and jQuery have feature detection built in, but my understanding is that Modernizr is more complete. I'm planning to use Modernizr for feature detection unless there is a good reason to use jQuery for this.
My application is intended to only work with more modern browsers (such as IE7+, Firefox, Chrome, Safari, and newer Opera), however it still works somewhat in IE6. I'd like to make sure the users see a big fat warning if they are using an older browser such as IE6. I'd also like to display a "suggestion" to upgrade to Chrome or some other HTML5 compliant browser if they are not using one already.
I don't want to use user agent testing.
- Is there a specific list of features that I should test for in order to determine if the user is using IE6 or not?
- Is there a specific list of features that I should test for to determine if the user is browsing with a fairly compliant HTML5 browser (Chrome, Safari, IE9, etc.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您说您正在使用 HTML5Boilerplate。在index.html的最顶部是这样的:
所以使用jQuery,计划旧的javascript甚至css来简单地测试html上的ie6类是否存在。
You say you're using HTML5Boilerplate. At the very top of the index.html is this:
So using jQuery, plan old javascript or even css to simply test for the existence of the ie6 class on html.
使用条件注释进行 IE 版本测试。
至于其余的,您应该只测试您使用的功能,并且仅在使用它们时进行测试。这样您就可以优雅地降级,并且不会意外阻止正常运行的浏览器。
Use conditional comments for IE version testing.
As for the rest you should only test for features you use and only when you use them. That way you will degrade gracefully and won't accidently block a browser that works.