Moses
Moses

Reputation: 9173

IE Compatibility Mode Bug

Here is the code at the top of my page:

<!DOCTYPE html>

<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
    <meta charset="utf-8">
    <title></title>
    ...

I am using the conditional comment code from Paul Irish to make it easier to detect and address IE issues, however this code seems to be causing an issue in and of itself. The problem is, using the conditional comment code forces my page into IE8 compatibility mode, despite the fact that I explicitly declare ie=edge according to the MSDN guidelines.

Removing the conditional comment code around the html tag fixes the glitch and lets IE8 render in standards mode; however I would much rather find a solution that lets me keep the conditional code and still force IE to render in standards compliance mode. Keep in mind I don't have a .htaccess file to use as this site is using a windows/asp setup.

Upvotes: 7

Views: 8047

Answers (3)

sethbro
sethbro

Reputation: 1888

An empty comment at the beginning fixes it.

<!--[if IE_NEEDS_THIS]><![endif]-->
<!DOCTYPE HTML>
<!--[if lt IE 9]><html class="lt-ie9"><![endif]-->
<!--[if gt IE 8]><!--><html class="gt-ie8"><!--<![endif]-->
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<title>--</title>

But don't put a conditional comment around the meta tag. IE10 will fall into quirks.

Upvotes: 7

Werner
Werner

Reputation: 21

I've found if the comment at the beginning of the Documents, then the meta tag can also be in a comment.

It works anyway and then it is valid HTML5 !

<!–[if IE]><![endif]–>
 <!DOCTYPE html>
 <html lang="de">
 <head>

<title></title>
 <!–[if gte IE 8]><meta http-equiv="X-UA-Compatible" content="IE=Edge" /><![endif]–>

In this situation, like IE8 and IE9 but not the content="IE=Edge,Chrome"

So please only content="IE-Edge"

Upvotes: 2

thirtydot
thirtydot

Reputation: 228162

You said:

Keep in mind I don't have a .htaccess file to use as this site is using a windows/asp setup.

I assume that means you could get around the problem by specifying X-UA-Compatible as a HTTP response header, instead of as a meta tag.

If you're using Classic ASP, you could use this at the top of your file and get rid of the meta tag:
(I'm guessing you meant Classic ASP based on the the lack of ASP.NET related stuff in your profile)

Response.AddHeader "X-UA-Compatible", "IE=edge,chrome=1"

This answer is based on too much guessing for my liking, so it might plain not work.

Also, this question might help:

IE8 standards mode meta tag

Upvotes: 0

Related Questions