DD.*_*DD. 17 jsf internet-explorer facelets conditional-comments jsf-2
这是我在Eclipse中的源代码文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我在IE9中查看它时,它呈现文本:
<!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
Run Code Online (Sandbox Code Playgroud)
如果我查看来源它说:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Faces Servlet服务后源已更改的任何原因?
SJu*_*n76 17
已知问题,JSF渲染逃脱了评论.您可以使用<h:outputText escape="false">和HTML实体来解决它.您也可以使用OmniFaces <o:conditionalComment>以更好的方式解决它.另请参见展示网站:
该
<o:conditionalComment>呈现条件注释.条件注释是IE特定的功能,它使开发人员能够(根据客户端是否使用IE来评论HTML块),如果是这样,甚至是哪个版本.它们通常与CSS样式表结合使用,如下所示:Run Code Online (Sandbox Code Playgroud)<!--[if lte IE 7]> <link rel="stylesheet" href="ie6-ie7.css" /> <![endif]-->但是,Facelets会将注释的内容呈现为HTML转义,从而使其无法使用.
Run Code Online (Sandbox Code Playgroud)<!--[if lte IE 7]> <link rel="stylesheet" href="ie6-ie7.css" /> <![endif]-->此外,如果将
javax.faces.FACELETS_SKIP_COMMENTS上下文参数设置为true那么它甚至根本不会被渲染.你需要用丑陋的方法解决这个问题<h:outputText escape="false">.Run Code Online (Sandbox Code Playgroud)<h:outputText value="<!--[if lte IE 7]><link rel="stylesheet" href="ie6-ie7.css" /><![endif]-->" escape="false" />该组件旨在解决此问题.
Run Code Online (Sandbox Code Playgroud)<o:conditionalComment if="lte IE 7"> <link rel="stylesheet" href="ie6-ie7.css" /> </o:conditionalComment>请注意,您不能使用它,
<h:outputStylesheet>因为它将隐式地重新定位为直接子项<h:head>.
这有效:
<h:outputText escape="false" value="<!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->"></h:outputText>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6421 次 |
| 最近记录: |