仅嗅探 IE8
如果浏览器是 IE8,那么嗅探的最短 JavaScript 代码是什么?
我想为 IE8 做一些特别的事情,
我不想连接一个可以返回所有浏览器和版本的库。 我只想写一两行来判断是否是IE8。
谢谢 佐
What's the shortest javascript code to sniff if the browser is IE8.
I want to do something special just for IE8
I don't want to wire up a library that gives me back all the browsers and the versions.
I just want to write one or two lines to work out if it's IE8.
thanks
zo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现的最好方法是使用条件样式或条件编译:
然后在代码中,您可以简单地检查此值:
The best way I found is to use conditional styles, or conditional compiling:
Then in your code, you can simply check this value:
您可以使用以下方法在 HTML 中执行此操作:
另请参阅本教程:http://msdn.microsoft.com/en-us/library/ms537509%28v=vs.85%29.aspx
You can do this in HTML, by using this:
Also take a look at this tutorial: http://msdn.microsoft.com/en-us/library/ms537509%28v=vs.85%29.aspx
在 HTML 中,您可以使用条件注释包含某些 IE 浏览器的标记:
In your HTML, you can include markup for certain IE browsers using conditional comments: