DanielShillock Posted December 12, 2011 Share Posted December 12, 2011 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 More sharing options...
Martin Honnen Posted December 12, 2011 Share Posted December 12, 2011 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 More sharing options...
DanielShillock Posted December 12, 2011 Author Share Posted December 12, 2011 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 More sharing options...
Martin Honnen Posted December 12, 2011 Share Posted December 12, 2011 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 More sharing options...
DanielShillock Posted December 12, 2011 Author Share Posted December 12, 2011 Wait, I'm a little confused. i understand what you've said but haven't I set HTML to HTML5 in the example I gave? Link to comment Share on other sites More sharing options...
Martin Honnen Posted December 12, 2011 Share Posted December 12, 2011 Not in my understanding as you use the XHTML namespace on your root element. With HTML5 you should not use any namespace and you should set <xsl:output method="html" version="5.0"/> Link to comment Share on other sites More sharing options...
DanielShillock Posted December 12, 2011 Author Share Posted December 12, 2011 Aah right I see. Unfortunately I still get the same error. I have tried setting HTML5 (at the expense of my CSS!) and also trying to dump the code into an external file with no avail. Link to comment Share on other sites More sharing options...
Martin Honnen Posted December 12, 2011 Share Posted December 12, 2011 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 More sharing options...
DanielShillock Posted December 14, 2011 Author Share Posted December 14, 2011 Thank you for your responses, I have sourced the issue. I am using a lightbox script which relies on prototype and a tooltip script which relies on jQuery. Using both of these conflict. Many thanks for your responses, it is greatly appreciated! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.