Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 566
Moses Avatar asked Feb 24 '11 22:02

Moses


1 Answers

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.

like image 90
getsetbro Avatar answered Sep 30 '22 07:09

getsetbro