Jump to content

Invoking Javascript In Xml


DanielShillock

Recommended Posts

Hi guys, I'm working on building an XML document (I've had some great help from this site already!) however, I am having trouble invoking Javascript in my XSLT. Whenever I use the javascript in the following format I get an error <script language="javascript"> Script here</script> I get the error "object does not support this property or method" Any ideas? I've been stumped for some time! Many thanksDaniel

Link to comment
Share on other sites

Please provide minimal but complete samples allowing us to understand and reproduce the problem. Currently it is not even clear whether you want to use Javascript in a HTML document which is the result of an XSLT transformation or whether you want to use Javascript in XSLT itself. And we don't get any information at all as to which code you have that causes that error message, which browser that is that gives that error message.

Link to comment
Share on other sites

Aha, my apologises. I would like to use Javascript in a HTML document. Here is a basic outline of the XSL I am using. I have tried placing the script tags in the HEAD of the HTML but I get the same error.

<html xmlns="http://www.w3.org/1999/xhtml"	   xml:lang="en" lang="en"	  ><head>  <title>Documentation</title>  <link type="text/css" rel="stylesheet" href="css/documentation.css"/>  <link type="text/css" rel="stylesheet" href="css/lightbox.css" media="screen"/>   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>   <script type="text/javascript" src="js/prototype.js"></script>   <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>   <script type="text/javascript" src="js/lightbox.js"></script>   <script type="text/javascript" src="js/jquery.qtip.js"></script>   <script type="text/javascript" src="js/jquery.qtip.min.js"></script></head><body>   <xsl:apply-templates/>   <xsl:text disable-output-escaping="yes">    <![CDATA[  <script language="javascript">$(document).ready(function(){	// Match all <a/> links with a title tag and use it as the content (default).   $('a[title]').qtip();});</script>   ]]></xsl:text></body></html>

Link to comment
Share on other sites

Well having XSLT 1.0 generate XHTML with inline script to be served as text/html can be challenging, I would strongly suggest to use HTML 4 or HTML5 if you want to use inline script or if you really need to create XHTML then not to use inline script but rather to put all script code into external script files.

Link to comment
Share on other sites

First try the script code in a static HTML document (i.e. one that is not generated by XSLT). If it works that way but not when you try it with the result document of an XSLT transformation then it is a topic for this forum but we would then really need a URL where we can visit the problem, considering all the script code that is linked in.If you get the script error with a static HTML document then please try the Javascript forum http://w3schools.invisionzone.com/index.php?showforum=26.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...