Add IE Edge meta tag after title tag from ASP include

Kfunk picture Kfunk · Oct 2, 2013 · Viewed 7.8k times · Source

I have thousands of pages on a CMS driven site that render poorly from within the company network because IE treats them as intranet pages, and the default setting for IE is to render intranet pages in compatibility mode.

I want to insert the IE Edge meta tag after the title tag to force the browser into its latest version, but I can't edit every page for this. To avoid editing individual pages or having to regenerate pages in the CMS, I think I should be able to update an include that is common to all pages with a server side script that does it. Is that possible? I think it needs to be server side because adding the meta tag at onload doesn't force the browser mode, but maybe I'm wrong.

So I want this:

<head>
...some stuff...
<title>My Title</title>
...some other stuff...
<!--#include virtual="/myinclude.asp"-->
</head>

To become this:

<head>
...some stuff...
<title>My Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
...some other stuff...
...rendered include...
</head>

Is there a way to do this? Or some other workaround I'm not seeing?

Answer

Kfunk picture Kfunk · Oct 3, 2013

It turns out you can add things to the header with this:

<%  Response.AddHeader "CustomHeader","CustomValue" %>

It also appears that it doesn't matter where I put it on the page, so I can stick it in the common include, and all pages will get the custom header. In this case:

<% Response.AddHeader "X-UA-Compatible","IE=Edge,chrome=1" %>

Wish I had known about this way sooner! Here's the spec:

http://msdn.microsoft.com/en-us/library/ms524327(v=vs.90).aspx