[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Dynamically changing and running Javascript after

Subject: RE: Dynamically changing and running Javascript after XSL transform
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Tue, 13 May 2003 12:53:36 -0400
javascript after load
[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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.