Jump to content

Cannot call javascript function in xsl


bonyka
 Share

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...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...