I do the transformation in the browser - the server does the perl script and
gives me XML. Then I want to transform it, but also change some javascript
and run it instantly, updating the current html page.
I tried your test and am not getting it called, though. I tried the onLoad
call to call a function, too.
-----Original Message-----
From: Passin, Tom [mailto:tpassin(_at_)mitretek(_dot_)org]
Sent: Tuesday, May 13, 2003 12:54 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Dynamically changing and running Javascript after XSL
transform
[Kathleen Kappers]
So I run the
XML through an
XSL transform to give me my new HTML, which I then stuff
right into the
current HTML file. All this works great, and saves me from
doing a load of
some new HTML page, which is the ideal solution.
Do you mean that you do this transformation in the browser? Because
your description sounds like you do all the work on the server, what
with the perl scripts and all.
The problem is I also need to dynamically change some
javascript. I need to
update some global variables that are in the original HTML
file, plus call a
refresh function in the original HTML, to add the new buttons
into this
button array, etc.
My question is how do you write javascript in an XSL file and
get it to
actually run, without doing a reload of the page or a load of
a new page?
If you really mean to do this on the browser, could probably also use a
stylesheet to create a string containing javascript objects with the new
data you want. Whatever call you make to to the transform would take
the return string and eval() it to insert the data into your javascript
variables.
eval() is your friend here. Here is a simple example you can try out -
<body>
<script type='text/javascript'>
var str = 'alert("This is a test")'
eval(str)
</script>
</body>
Just write a string containing the javascript you want to execute, and
let eval() do the work.
If for some reason you cannot make that work, I would consider writing
your transform results to an invisible Iframe (it can be made invisible
by giving it a CSS style of 'display:none'). Include some javascript
that can write the desired javascript data to the parent frame and
invoke it on the Iframe's onLoad event.
This is getting pretty far OT for this list, though.
Cheers,
Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
---
This email message and any attachments are for the sole use of the intended
recipient(s) and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited. If you are
not the intended recipient or his/her representative, please contact the sender
by reply email and destroy all copies of the original message.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list