在我的标准网页中,我有以下代码,但如何在XPage中执行此操作?
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
您可以通过向UIViewRoot组件添加属性来执行此操作:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.attrs>
<!-- if browser is IE 7 or smaller -->
<xp:attr name="class" value="no-js lt-ie9 lt-ie8 lt-ie7"
rendered="#{javascript:context.getUserAgent().isIE(0,7)}">
</xp:attr>
<!-- if browser is NOT IE 7 or smaller -->
<xp:attr name="class" value="no-js lt-ie9 lt-ie8 lt-ie7"
rendered="#{javascript:!(context.getUserAgent().isIE(0,7))}">
</xp:attr>
</xp:this.attrs>
</xp:view>
Run Code Online (Sandbox Code Playgroud)
在郎属性由XPage上的当前语言设置来计算.要在此应用程序/服务器范围内执行此操作,您必须将其添加到主题中.
编辑:
主题必须如下所示:
<control>
<name>ViewRoot</name>
<property>
<name>attrs</name>
<complex type="xp_attr">
<property>
<name>name</name>
<value>class</value>
</property>
<property>
<name>value</name>
<value>#{javascript:
if (context.getUserAgent().isIE(0,6)) {
return 'no-js lt-ie9 lt-ie8 lt-ie7';
}
if (context.getUserAgent().isIE(7,7)) {
return 'no-js lt-ie9 lt-ie8';
}
if (context.getUserAgent().isIE(8,8)) {
return 'no-js lt-ie9';
}
return '';
}</value>
</property>
</complex>
</property>
</control>
Run Code Online (Sandbox Code Playgroud)
空返回是必需的,否则主题将失败.
| 归档时间: |
|
| 查看次数: |
1141 次 |
| 最近记录: |