覆盖SharePoint 2010中与X-UA兼容的元 [英] overwrite X-UA-Compatible meta in SharePoint 2010

查看:79
本文介绍了覆盖SharePoint 2010中与X-UA兼容的元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SharePoint 2010,并且想使用 <meta http-equiv="X-UA-Compatible" content="IE=edge"/> 用于特定页面. 母版页将其设置为"IE = 8",这不允许我在CSS中使用盒子阴影.

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.

所以我的问题是:有没有办法在一个简单的页面(.aspx)中覆盖X-UA兼容的元标记?

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

推荐答案

  • 通过X-UA-compatible HTTP标头:Web服务器已通过HTTP标头请求了旧版文档模式.
  • 通过X-UA-compatible 元标记:网页开发人员使用元标记来指定旧版文档模式.
    • 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的默认母版页硬编码X-UA-Compatible元标记,并且元标记优先于HTTP标头,因此不能在HTTP级别上完成.这给了我们第二个选择.

    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.

    似乎页面上遇到的第一个X-UA-compatible元标记已被IE使用(尽管在不同的文章中它是模棱两可的,而在MSDN文档中却没有).如果您编写SharePoint UserControl或WebPart,则可以添加以下代码,例如在Page_Load()方法中将此标头添加为第一个标头:

    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);
    

    其中HtmlMeta来自System.Web.UI.WebControls命名空间.

    通过迭代Page.Header.Controls,您可能还可以找到并删除SharePoint默认添加的元标记,尽管上面的代码似乎足以触发IE11中的Edge模式.

    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.

    这篇关于覆盖SharePoint 2010中与X-UA兼容的元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆