2012-06-06 15 views
2

是否有可能向xpage添加条件样式表。添加有条件的CSS样式表到xpage

做过这样的以html:

<!--[if lt IE 8]><link rel="stylesheet" href="../../blueprint/ie.css" type="text/css" media="screen, projection"><![endif]--> 

虽然与计算字段设置为HTML和代码有关添加JavaScript,如:

return '<!--[if lt IE 8]><link rel=\"stylesheet\" href=\"../../blueprint/ie.css\" type=\"text/css\" media=\"screen, projection\"><![endif]-->' 

但随后它会被包含在页面的主体,而不是其他样式表的标题。

需要将概念证明放在一起使用http://blueprintcss.org

回答

5

一个XPage主题是为这个伟大的。有一个示例包含在笔记安装中。

到C:\ Notes目录 \ XSP \ NSF \主题

使webStandard.theme的复制,重命名为webStandard。 xml并在您选择的编辑器中打开,这会向您展示很多主题可以执行的操作。应用属性,添加资源,计算这些通过表情等

段:

<resource rendered="#{javascript:context.isDirectionRTL()}"> 
     <content-type>text/css</content-type> 
     <href>/.ibmxspres/global/theme/webstandard/xspRTL.css</href> 
    </resource> 

    <!-- IE Specific --> 
    <resource rendered="#{javascript:context.getUserAgent().isIE(0,6)}"> 
     <content-type>text/css</content-type> 
     <href>/.ibmxspres/global/theme/webstandard/xspIE06.css</href> 
    </resource> 
    <resource rendered="#{javascript:context.getUserAgent().isIE(7,8)}"> 
     <content-type>text/css</content-type> 
     <href>/.ibmxspres/global/theme/webstandard/xspIE78.css</href> 
    </resource> 
+0

这可能是最好的办法。另请参阅此处(http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_themes)以获取有关如何使用主题的一些准则。 –

5

可以使用渲染属性与SSJS以显示仅IE的元素:

渲染= “#{的javascript:context.getUserAgent()isIE()}”

然后,只有在使用Internet Explorer打开XPage时,才会将CSS资源添加到生成的HTML响应中。

编辑:
你的情况,这应该符合你的要求:

<xp:this.resources> 
    <xp:styleSheet href="../../blueprint/ie.css" 
     rendered="#{javascript:context.getUserAgent().isIE(0,7)}" 
     media="screen, projection"> 
    </xp:styleSheet> 
</xp:this.resources> 
+0

酷!这是通过概念验证做到的。谢谢! – Derek