开发者

IE8 takes on class name of IE7 when using conditional comments

开发者 https://www.devze.com 2023-03-05 12:46 出处:网络
I have seen a couple of answers that relate to my questions but can\'t seem to get the problem solved.

I have seen a couple of answers that relate to my questions but can't seem to get the problem solved.

I am trying to use the conditional comments to target IE as per Paul Irish Boilerplate i.e.

<!--[if lt IE 7 ]> <body class="ie6"> <![endif]--> 
<!--[if IE 7 ]>    <body class="ie7"> <![endif]--> 
<!--[if IE 8 ]>    <body class="ie8"> <![endif]--> 
<!--[if IE 9 ]>    <body class="ie9"> <![endif]--> 
<!--[if gt IE 9]>  <body> <![endif]-->
<!--[if !IE]><!--> <body> <!--<![endif]-->

Doctype is 'transitional'.

I am testing a site on a local server and looking at the developer toolbar in IE8, the class that is placed on the body is 'ie7'

After a looking into to it I am using the following to try and render in IE8 standards mode hoping that the class put on the body would be 'ie8'

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

It doesn't work. I also used the JS here to tell my what mode IE8 is in. Its says IE8 standards mode.

Any ide开发者_如何学Goa how I can get the class on the body of IE8 to read 'ie8'? Or at least, not 'ie7' like it currently does.

Or is it just not possible to do this testing on a local server meaning I have to put it on a live server before I can make the changes I want? Which seems a bit crazy...

Thanks


If you are using a local server you are probably in IE8 compatibility mode. This is the default for local sites.

To check hit F12 and the developer toolbar should load. It will show you what browser mode and document mode you are using. IE8 should display for both.

You can disable the default behaviour by clicking "Tools" > "Compatibility View Settings" and change the setting "Display intranet sites in compatibility mode".


According to this page: "Note that IE8 claims to be 7 in Compatibility View"

If the excellent people at JQuery can't seem to sort that out, then I think the answer is probably no. :/


If IE8 is in IE7 mode then the browser is correct to report itself as IE7; after all, the intention of IE7 mode is to render the page exactly the way IE7 would have done, so if you're doing browser detection, you would want to be told it's IE7 because it's the IE7 behaviour you would have to deal with (the fact that there are bugs with IE8's IE7 mode, and that it isn't quite the same as a real IE7 is another topic altogether).

What you seem to be wanting is IE8 to actually be in IE8 mode. This is a reasonable thing to want!

You said you're using:

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

have you tried this instead:

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

'edge' tells IE to use the most up-to-date rendering engine it has, which should force IE8 to go into normal IE8 mode. Maybe that would work better than telling IE8 to emulate itself?

By the way, if you're having trouble on machines in your local network with IE8 falling back to IE7 mode when you're not expecting it, be aware that there is a config setting in IE8 which specifies to "always use IE7 mode for intranet sites". This feature was put there by Microsoft to help with backward compatibility of custom-written intranet sites which didn't upgrade nicely to IE8, but frankly it causes more hassles than it saves. If this is the problem and you can't solve it any other way, you may find the easiest answer is simply to go to all the machines on your network and change the config setting (depending on the size of your network, of course!).

0

精彩评论

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