2013-05-14 145 views
0

我不是这方面的专家。我做了一些搜索,但没有找到我正在寻找的东西。希望这很简单。XSL后退按钮

我的工作,有一个内置的Web服务器软件控制系统。在这个系统的导航过程中有一些要点,唯一的出路是使用网页浏览器后退按钮(不幸的是,我知道)。

对于使用该运营商来说,他们通常在屏幕上所有的导航,并突然与有“没有出路”可能会引起混淆显示器呈现。

我想修改layout.xsl文件,添加一个后退按钮。 (如果它的事项,它只是曾经打算为Internet Explorer,因为系统是基于ActiveX)

下面是该文件的相关部分:

<table id="Menu" class="Header" border="0" cellspacing="0" cellpadding="0" width="100%"> 
    <tr> 
    <td width="100%"> 
     <table class="menuBar" border="0" cellspacing="0" cellpadding="0"> 
     <tr height="0"> 

      <xsl:for-each select="Links/Link"> 
      <xsl:if test="text() != 'Lists'"> 
       <xsl:if test="text() != 'Database'"> 
       <xsl:if test="text() != 'Favorites'"> 
        <xsl:if test="text() != 'Log Off'"> 
        <xsl:if test="text() != 'Help'"> 
         <xsl:call-template name="Button"> 
         <xsl:with-param name="href" select="@href"/> 
         <xsl:with-param name="text" select="text()"/> 
         <xsl:with-param name="last" select="boolean(position() = count(../Link))"/> 
         </xsl:call-template> 
        </xsl:if> 
        </xsl:if> 
       </xsl:if> 
       </xsl:if> 
      </xsl:if> 
      </xsl:for-each> 

      <th class="rightbar" align="right" valign="top"/> 
     </tr> 
     </table> 
    </td> 
    </tr> 
</table> 

<xsl:template name="Button"> 
    <xsl:param name="href"/> 
    <xsl:param name="text"/> 
    <xsl:param name="last"/> 

    <th width="auto" height="20" class="deselected" valign="center"> 
    <xsl:element name="a"> 
     <xsl:attribute name="href"> 
     <xsl:value-of select="$href"/> 
     </xsl:attribute> 
     <xsl:value-of select="$text"/> 
    </xsl:element> 
    </th> 
    <th width="5" class="deselected" valign="middle"> 
    <img src="/file/images/submenumid.png" width="5" height="20"/> 
    </th> 
</xsl:template> 

你会看到表多次调用按钮模板。如果你感到困惑,这些线,

<xsl:if test="text() != 'xxxx'"> 

那些被我加入到过滤掉现有的按钮,我不想显示。

什么我希望的是有一个名为back button类似的模板,将发送一个回命令到Internet Explorer。我会先致电back button模板,以便它是最左边的项目。提前

谢谢你,让我知道是否需要任何额外的信息!

+0

我应该注意,params都来自代码示例以外。但这对于这个问题确实不重要。 – Nate

+0

即使在XSLT 1.0中也有'和'。没有必要嵌套'xsl:if'元素! – Borodin

回答

0
<table id="Menu" class="Header" border="0" cellspacing="0" cellpadding="0" width="100%"> 
     <tr> 
      <td width="100%"> 
       <table class="menuBar" border="0" cellspacing="0" cellpadding="0"> 
        <tr height="0"> 
         <xsl:call-template name="Button"> 
          <xsl:with-param name="href">javascript:history.back()</xsl:with-param> 
          <xsl:with-param name="text">Go Back</xsl:with-param> 
          <xsl:with-param name="last" select="false()"/> 
         </xsl:call-template> 

         <xsl:for-each select="Links/Link"> 
          <xsl:if test="text() != 'Lists' 
          and text() != 'Database' 
          and text() != 'Favorites' 
          and text() != 'Log Off' 
          and text() != 'Help'"> 
           <xsl:call-template name="Button"> 
            <xsl:with-param name="href" select="@href"/> 
            <xsl:with-param name="text" select="text()"/> 
            <xsl:with-param name="last" select="boolean(position() = count(../Link))"/> 
           </xsl:call-template> 
          </xsl:if> 
         </xsl:for-each> 

         <th class="rightbar" align="right" valign="top"/> 
        </tr> 
       </table> 
      </td> 
     </tr> 
    </table> 

这是最后确定的代码。由于鲍罗丁的建议,我清理了很多'如果'的陈述。 我还使用history.back()链接向Button模板添加了一个新的调用,而不是添加新的模板。

感谢您的帮助球员

1
<xsl:template name="BackButton"> 
    <xsl:param name="last"/> 

    <xsl:call-template name="Button"> 
    <xsl:with-param name="href" select="javascript:window.history.back()"/> 
    <xsl:with-param name="text" select="Go back"/> 
    <xsl:with-param name="last" select="$last"/> 
    </xsl:call-template> 
<xsl:template/>