如何使元标记成为 <head> 中的第一个部分? [英] How to make a meta tag the first one in the <head> section?

查看:9
本文介绍了如何使元标记成为 <head> 中的第一个部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 JSF2、GlassFish 3.1、PrimeFaces 2.x.

I'm using JSF2, GlassFish 3.1, PrimeFaces 2.x.

我在 IE9 上遇到了奇怪的渲染问题.我应该能够通过插入以下内容来强制 IE9 呈现为 IE9:

I'm having strange rendering problems on IE9. I'm supposed to be able to force IE9 to render as IE9 by inserting the following:

<html>
<head>
  <!-- Enable IE9 Standards mode -->
  <meta http-equiv="X-UA-Compatible" content="IE=9" />
...

但问题是,它不起作用,因为(我被告知)元标记必须是该部分中的第一个标记.

But the thing is, it's not working because (I'm told) the meta tag MUST be the first tag in the section.

当我在 XHTML 文件中执行此操作时...

When I do this in my XHTML file ...

<html ...>

<f:view contentType="text/html" locale="#{loginHandler.currentLocale}">

<h:head>
    <!-- Enable IE9 Standards mode -->
    <meta http-equiv="X-UA-Compatible" content="IE=9" />

生成的 HTML 看起来像这样,其中 JSF/PrimeFaces 在我的新元标记之前插入了一堆链接"和脚本"标记.

The resulting HTML looks like this, where JSF/PrimeFaces has inserted a bunch of "link" and "script" tags before my new meta tag.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" rel="stylesheet" href="/orcf-webui/javax.faces.resource/jquery/ui/jquery-ui.css.jsf?ln=primefaces&amp;v=2.2" />
<link type="text/css" rel="stylesheet" href="/orcf-webui/javax.faces.resource/wijmo/wijmo.css.jsf?ln=primefaces&amp;v=2.2" />
<script type="text/javascript" src="/orcf-webui/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&amp;v=2.2"></script>
<script type="text/javascript" src="/orcf-webui/javax.faces.resource/jquery/ui/jquery-ui.js.jsf?ln=primefaces&amp;v=2.2"></script>
<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=9" />

有什么办法可以让我的元标记放在正确的位置,这样它就可以工作了吗?(或者让这个 IE9 问题消失的替代方法?

Is there any way to get my meta tag in the right place so it will work? (Or an alternative way to make this IE9 problem go away?

推荐答案

  1. 元标记必须在所有 PrimeFaces 内容之前:http://blogs.msdn.com/b/cjacks/archive/2012/02/29/using-x-ua-compatible-to-create-durable-enterprise-web-applications.aspx

HTTP Header 和 HTML HEAD 是完全不同的东西.

HTTP Header and HTML HEAD are completly different things.

在 PrimeFaces 3.0 中,新的 facet 被添加到 h:head:http://blog.primefaces.org/?p=1433所以解决方案是:

In PrimeFaces 3.0 the new facet was added to h:head: http://blog.primefaces.org/?p=1433 So the solution would be:

<h:head>
    <f:facet name="first">
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
    </f:facet>
</h:head>

这篇关于如何使元标记成为 &lt;head&gt; 中的第一个部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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