Jump to content

Cannot call javascript function in xsl


bonyka

Recommended Posts

Hey, guys.I want to insert javascript function in my xsl file, but i cannot call it.It seem it doesn't work.xsl file ----------------------------------------------------<!xml version="1.0" encoding="iso-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/><xsl:template match="/"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/><title>test</title><script type="text/javascript"> function greeting() { document.write("hello, i'm bonyka,"); }</script></head><body><table> <tr> <td onclick="greeting()"> <xsl:value-of select="name" /> </td> </tr></table></body></html></xsl:template></xsl:stylesheet>------------------------------------------------thanks,bonyka

Link to comment
Share on other sites

Apart from the wrong XML prolog (note the "!". It should be "?"), try to mark your script in CDATA like so:

<script type="text/javascript"><![CDATA[function greeting(){document.write("hello, i'm bonyka,");}]]></script>

Link to comment
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...