Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 master page is setting it to "IE=8" which doesn't allow me to use box-shadow in CSS e.g.

I don't have access to the masterpage to change it. Also I have read that changing that meta in master page is not recommended as it might cause issues with other things like calendars or whatever.

So my Q is: is there any way of overwriting the X-UA-Compatible meta tag in a simple page (.aspx)?

like image 861
Rapsöl Avatar asked Oct 08 '14 12:10

Rapsöl


1 Answers

Among the ways to change the compatibility mode for page two of them seems promising:

  • Via X-UA-compatible HTTP header: The web server has requested a legacy document mode via an HTTP header.
  • Via X-UA-compatible meta tag: The webpage developer used a meta tag to specify a legacy document mode.

SharePoint 2010's default master page hardcodes X-UA-Compatible meta tag, and meta tag takes precedence over HTTP header, so this can't be done on HTTP level. This leaves us with the second option.

It seems that the first X-UA-compatible meta tag encountered on the page is used by IE (although it's ambiguous in different articles and missing in MSDN documentation). If you write SharePoint UserControl or WebPart you might add this code e.g. in Page_Load() method to add this header as the first one:

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

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

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

like image 184
Paweł Bulwan Avatar answered Nov 16 '22 05:11

Paweł Bulwan