有没有办法用元标记进行 If IE8 检查?

发布于 2024-11-30 10:03:22 字数 424 浏览 6 评论 0原文

或者也许是javascript? 我有一个在 ie7 + 现代浏览器中运行良好的布局。但ie8不行。

我发现我可以使用这个:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

并且 IE8 假装是 IE7,并正确渲染所有内容,但随后它会弄乱所有好的浏览器(基于 webkit、基于 gecko 等)。

我知道在正文中,您可以执行以下操作:

<!--[if IE 8]>
    ie8 specific javascript, html, or css
<![endif]-->

但我在元标记周围的 中尝试过这样做,但它不起作用

or maybe javascript?
I have a layout that works well in ie7 + modern browsers. But not ie8.

I found out that I can use this:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

and IE8 pretends to be IE7, and renders everything correctly, but then it messes up all the good browsers (webkit-based, gecko-based, etc).

I know that in the body, you can do things like:

<!--[if IE 8]>
    ie8 specific javascript, html, or css
<![endif]-->

But I tried that in the <head> around the meta tag, but it didn't work

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缘字诀 2024-12-07 10:03:22

我发现,由于我在 Rails 上使用 ruby​​,我只需询问请求变量浏览器要求获取页面即可。

<% if request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/%>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
<% end %>

I found out that since I'm using ruby on rails, I can just ask the request variable what browser asked to get the page.

<% if request.env["HTTP_USER_AGENT"] =~ /MSIE 8.0/%>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
<% end %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文