Вопрос

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?

Это было полезно?

Решение

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

Другие советы

You can set IIS to send the header for all pages served. An MSDN article describes the steps as:

Configuring the EmulateIE7 HTTP Header in IIS7 (via the user interface)

  1. Open Internet Information Services (IIS) Manager
  2. Select the Server from the connections pane
  3. Right-click on “HTTP Response Headers” from the center task pane, and choose “Open Feature”
  4. Select “Add” from the Actions Pane
  5. Add a custom header with the Name “X-UA-Compatible” and the Value “IE=Edge”

They also have the steps for making the changes via command line.

There's an article on the IIS Blog that gives you a list of possible values and what they will do.

Emulate IE8 mode  -->   IE=EmulateIE8
Emulate IE7 mode  -->   IE=EmulateIE7
IE5 mode          -->   IE=5
IE7 mode          -->   IE=7.5
IE8 mode          -->   IE=8
Edge mode         -->   IE=Edge
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top