Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X-UA-Compatibility with HTTP Header

actually i'm having a problem with a website in IE which is not on intranet and the "always show pages in compatibility mode is not activated" but it still opens in quirks mode sometimes, despite adding

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

I have red that i can send this compatibility order in an HTTP Header or in htaccess

My problem is that i have searched on how to send an HTTP header and actually found no clue, and btw i'm a php developer just in case this information was necessary.

I would really appreciate if someone could provide me what's needed to add (for both, or for one at least) and how/where to add it, i have been looking for the whole week and it's quiet urgent to find the fix so soon !

Is this way to send it as an HTTP header as a first line in the page is right ?

<?php
header('X-UA-Compatible: IE=edge');
?>

(I have just found it)

I really appreciate any help can be provided and i'm thankful in advance.

like image 471
Mahmoud Jabado Avatar asked Mar 16 '13 00:03

Mahmoud Jabado


People also ask

Does X UA need compatible?

X-UA-Compatible is a document mode meta tag that allows web authors to choose what version of Internet Explorer the page should be rendered as. It is used by Internet Explorer 8 to specify whether a page should be rendered as IE 7 (compatibility view) or IE 8 (standards view).

What is content IE edge in HTML?

IE=edge means IE should use the latest (edge) version of its rendering engine. chrome=1 means IE should use the Chrome rendering engine if installed.

What is IE and edge?

What is IE mode? IE mode on Microsoft Edge makes it easy to use all of the sites your organization needs in a single browser. It uses the integrated Chromium engine for modern sites, and it uses the Trident MSHTML engine from Internet Explorer 11 (IE11) for legacy sites.


1 Answers

As you correctly noted the header can be set in php:

<?php header('X-UA-Compatible: IE=edge,chrome=1');

It can also be set in .htaccess like so:

<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 "\.(appcache|crx|css|eot|gif|htc|ico|jpe?g|js|m4a|m4v|manifest|mp4|oex|oga|ogg|ogv|otf|pdf|png|safariextz|svg|svgz|ttf|vcf|webm|webp|woff|xml|xpi)$">
    Header unset X-UA-Compatible
  </FilesMatch>
</IfModule>

(copied from the HTML5 Boilerplate template)

However, if you are setting these headers and finding that IE still defaults to quirks-mode then I'd be inclined to suggest that there is something else at work. Have you ensured that your pages include a valid doctype? Notably one that isn't of the HTML 4.01 flavour.

like image 147
Emissary Avatar answered Nov 08 '22 21:11

Emissary