0

I have XSLT given below. It's just calling JavaScript after clicking one button. But that alert is not displayed. I tried calling that in onload function as well but that also does not work. Please help. Thanks.

<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" />
    <!-- INCLUDE TEMPLATES -->
    <xsl:include href="../../../../xsl/Common.xsl" />
    <xsl:include href="../../../xsl/DMenu/DMenuCommon.xsl"/>
    <!-- MAIN TEMPLATE -->
    <xsl:template match="/">
    <html>
<head>
<script type="text/javascript">

<xsl:comment>

function  ManageAppButton() 
          { 
          alert("XX");
          }

</xsl:comment>

</script>

</head>
        <body onload="ManageAppButton();">
    <table align="centre" border="1">
    <tr><thead align="center">Deployed</thead></tr>
                 <tr>
                    <th>Application</th>
                    <th>Tickets</th>                    
                </tr>
            <tbody>
                <xsl:for-each select="root/DepRs/DepRd">
                    <tr><td><xsl:value-of  select="application" /></td>
                    <td><xsl:value-of  select="notickets" /></td>
                </tr>
                </xsl:for-each>
                <tr><td>asf</td></tr>
            </tbody>
        </table>
        <button  type="button"> 
        <xsl:attribute name="onClick" >ManageAppButton();</xsl:attribute><font style="font-size:10px">Update</font></button>    
        </body> 
        </html>
</xsl:template>
</xsl:stylesheet>
Laura
  • 3,233
  • 3
  • 28
  • 45
Tej
  • 1
  • 1
    Just to be clear: the XSLT is not calling Javascript. All the XSLT is doing is generating an HTML page containing embedded Javascript. Try hand-coding the HTML you want, testing it, and then writing the XSLT needed to generate it. (If you want an XSLT stylesheet that can actually handle user events directly, rather than just generating an HTML page, take a look at Saxon-JS). – Michael Kay Jun 24 '17 at 14:31

1 Answers1

0

Please see this link in regards to best practices when it comes to HTML comments in JavaScript script tags. It's no longer recommended and can cause some issues. Try removing the xsl:comment tags and just have the JavaScript inside the script node.