Re: [xsl] embedded javascript in generated html doesn't work in internet explorer

Subject: Re: [xsl] embedded javascript in generated html doesn't work in internet explorer
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 19 Oct 2006 01:03:42 +0200
Hi Branko,

I found your question a bit unclear, but after looking at your documents, it seems that what you are trying to do is embedding script-elements in an XSLT stylesheet and expecting them to be run when you insert the resulting DOM tree into the browsers DOM tree.

Well, every now and then it will work the way you expect it to. And in this simple example you are lucky to have it working in FF. I'd like to start a discussion about the pros (little) and cons (many) of using script tags from xslt and interpreting them in the browser, but I won't bother you with it. Instead, look up the excellent prototype.js (http://www.sergiopereira.com/articles/prototype.js.html) library, which has built in methods to get these script tags working in any browser. They did the hassle for you.

Since prototype does not help you so much with xslt (but it does with many many other things), you may also consider Sarissa (http://sarissa.sf.net), which gives you a generalized view of the XSLTProcessor and XMLHttpRequest objects from any browser.

Btw(1), in case you are interested, the trick pulled by prototype.js is to extract the script-tags, store them separately and execute them separately.

Btw(2), you may found the same problems (or close) when trying to embed <style> tags from xslt. It will work sometimes and it won't the other.

Btw(3), there are some mailing list on these particular subjects.

Cheers,
-- Abel Braaksma
  http://www.nuntia.com


Branko Kokanovic wrote:


I'm struggling to get embedded javascript work in IE 6.0. I'm using
javascript to generate inner html from xsl and xml. Inside xsl is
<script> (javascript) that works in mozilla, but just get ignored in
IE. I searched throught archive, but nobody asked anything similar, so
it must be my weak precognition of XSLT. I made stripped-out example
at:

Current Thread