Overwrite X-UA-compatible meta in SharePoint 2010

I am working on SharePoint 2010 and I want to use <meta http-equiv="X-UA-Compatible" content="IE=edge"/> for a specific page. The main page is set to "IE = 8", which does not allow me to use the shadow in CSS, for example.

I do not have access to the main page to change it. I also read that changing this meta on the main page is not recommended, as this can cause problems with other things, such as calendars or something else.

So my Q: is there a way to rewrite the X-UA-Compatible meta tag on a simple page (.aspx)?

+7
internet-explorer-10 x-ua-compatible sharepoint-2010
source share
2 answers

Among the ways to change the compatibility mode for the second page seem promising:

  • Via the X-UA-compatible HTTP header . The web server requested an outdated document mode through an HTTP header.
  • Via the X-UA-compatible meta tag . The web page developer used the meta tag to indicate the mode of the outdated document.

The master label metadata of the SharePoint 2010 X-UA-compatible master page, and the meta tag takes precedence over the HTTP header, so this cannot be done at the HTTP level. This leaves us with the second option.

It seems that the first X-UA-compatible meta tag that appears on the page is used by IE (although it is ambiguous in different articles and is not in the MSDN documentation). If you write SharePoint UserControl or WebPart, you can add this code, for example. in Page_Load() to add this header as the first:

  HtmlMeta metaEdgeIE = new HtmlMeta(); metaEdgeIE.HttpEquiv = "X-UA-Compatible"; metaEdgeIE.Content = "IE=EDGE"; Page.Header.Controls.AddAt(0, metaEdgeIE); 

where HtmlMeta comes from the System.Web.UI.WebControls .

Iterating through Page.Header.Controls you can probably also find and remove the meta tag added by default by SharePoint, although the code above seems sufficient to trigger Edge mode in IE11.

+7
source share

If you can edit the main page and want to change the compatibility for certain pages, you can take a similar approach to buli (thanks), but rewrite the existing meta tag content. For your meta tag on the main page, specify its id and runat server

 <meta id="metaIE" runat="server" http-equiv="X-UA-Compatible" content="IE=edge"> 

In your page load, find the control from the wizard, add to HtmlMeta and change the contents

 Dim metaIE = DirectCast(Master.FindControl("metaIE"), HtmlMeta) metaIE.Content = "IE=10" 
0
source share

All Articles