开发者

Is there a way to do an If IE8 check with meta tags?

or maybe javascript? I have a layout that works well in ie7 + mo开发者_如何转开发dern 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


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 %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜