internet-explorer - 如何确保放在元素内部的首位?
问题描述
我正在尝试解决以下问题:当我在 IE 中访问我的应用程序时,它会自动以 IE7 文档模式打开,而不是在 IE9 中打开。经过一番研究,我在这个网站上发现了一些信息:https ://code.i-harness.com/en/q/f10390 ,我知道我必须从中放置
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
在<head>元素中排在第一位。我相信我正在做的。但是,当呈现页面时,我在模板中定义的所有元素h:head都被放置在 bootsfaces 需要的其他 css 和 js 之后(jquery..etc)。
我什至在 web.xml 中添加了如下内容,因为它似乎需要覆盖
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
<context-param>
<param-name>BootsFaces_USE_VIEWPORT</param-name>
<param-value>false</param-value>
</context-param>
我的模板:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui"
xmlns:ds="http://deltaspike.apache.org/jsf">
<f:view contentType="text/html" encoding="UTF-8" >
<h:head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>My System</title>
<h:outputScript library="mySystem" name="js/mySystem.js" position="last" />
<h:outputStylesheet library="mySystem" name="css/mySystem.css" position="last" />
</h:head>
<h:body>
<ds:windowId />
...
有没有人能够启发我如何在 IE9 文档模式下实现所需的打开,或者如何实现生成 html,其中< meta http-equiv .../>是 head 元素内的第一行。提前致谢。
解决方案
好吧,一旦我找到解决方案,我会回答。不确定它是否是最好的:
我设法强制<meta>
节点排在第一位,使用
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
</f:facet>
我在这里找到了答案。 如何使元标记成为 <head> 部分中的第一个?
推荐阅读
- javascript - 将数字 1 - 100 打印到屏幕上,在 li 开头添加了额外的空白列表元素
- computer-vision - 使用 g2o 库进行捆绑调整。如何验证?
- php - 如何将数组值与子数组值进行比较
- c++ - 如何旋转 gtk 树视图以水平显示列?
- arduino - 带有 MQTT 代理的 Arduino Uno
- c - Visual C 结构数组 - 表达式必须有一个常量值
- javascript - 将可拖动元素悬停在其上时,从放置元素获取继续坐标
- javascript - 无法使用 AJAX + Wordpress 解析 xml 数据
- javascript - 如何返回 false 而不是“TypeError:无法读取属性”?
- python - 使用正则表达式读取特定格式