Cómo evitar que IE9 renderice sitios de intranet en modo de compatibilidad


IE9 tiene un problema extraño donde renderiza sitios de intranet en modo de compatibilidad.

¿Alguien sabe cómo evitar que esto suceda?

Nota: No estoy buscando una manera de prevenirlo en una sola máquina de usuarios, sino alguna forma programática para evitar que el sitio se renderice en modo de compatibilidad.

Author: novicePrgrmr, 2012-10-15

4 answers

Después de una búsqueda exhaustiva, descubrí cómo evitar con éxito que un sitio de intranet se renderice en modo de compatibilidad en IE9 en este blog :

Desde el blog de Tesmond

Hay 2 peculiaridades en IE9 que pueden hacer que el modo de compatibilidad permanezca en efecto. El elemento meta compatible con X-UA debe ser el primer elemento meta en la sección head. No puede tener sentencias condtional IE antes del elemento meta compatible con X-UA. Esto significa que si usas Paul El maravilloso Boilerplate HTML5 de Irish luego en una Intranet con la configuración predeterminada de IE9, su sitio web se mostrará en modo de compatibilidad. Necesitas cambiar el inicio del boilerplate de lo siguiente: -

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

A:

<!doctype html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
 31
Author: novicePrgrmr,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-16 08:40:39

Siguiendo la respuesta de @novicePrgrmr, parece haber una solución para IE9 cargando Intranets en modo IE7. Si bien esto todavía activa el modo de compatibilidad, encontré una ligera modificación en El marcado HTML5 boilerplate de Paul Irish al menos permite que IE9 renderice Intranets en estándares IE9:

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

    <p>content</p>

</body>
</html>

Esto sigue siendo HTML válido, y el CSS existente específico de IE debería seguir funcionando bien, siempre que se apunte a IE usando .lt-ie en lugar de html.lt-ie.

 4
Author: Timmah,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-08-18 06:41:33

Esto se puede hacer agregando una etiqueta meta simple

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

Otra forma de lograr esto es agregar este código a su .archivo htaccess!

# ----------------------------------------------------------------------
# Better website experience for IE users
# ----------------------------------------------------------------------

# Force the latest IE version, in various cases when it may fall back to IE7 mode
#  github.com/rails/rails/commit/123eb25#commitcomment-118920
# Use ChromeFrame if it's installed for a better experience for the poor IE folk

<IfModule mod_headers.c>
  Header set X-UA-Compatible "IE=Edge,chrome=1"
  # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>
 3
Author: Ruud,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-15 11:07:59

Si puede agregar código a la página de inicio, simplemente puede agregar esto:

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

Al encabezado de su sitio web.

(También puede usar <meta http-equiv="X-UA-Compatible" content="IE=9"> para forzar IE9-Renderer) Esto obligará a IE9 a renderizar en modo estándar.

Otra forma es usar otro doctype: Pon esto al principio de tu código:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
 1
Author: jAC,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-15 10:59:23