This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: XSL and Javascript to set new window parameters
The best way (or just an alternative) to handle window.open's is to put it
in a function and call it from the click event. It has been my experience
that you get inconsistent results calling window.open directly.
so you could have a javascript function that is something like this (you may
want to parametize more stuff):
function gotoURL (thePage){
window.open(thePage,'new','toolbars=no,scrollbars=no')
}
then in your xsl/xml transform you would write out a line that looks like:
<a href="javascript:gotoURL('default.html');">Home</a>
note: you can call mutliple functions like this:
<a
href="javascript:gotoURL('default.html');loadVars();someOtherFunction();">Ho
me</a>
the XSL could look like this:
<!-- &srv_uri; is an entity that defines the fully qualified root of the
site -->
<a href="javascript:gotoURL('&src_uri;/<xsl:value-of
select="$theURLtoGoto"/>');">
<xsl:value-of select="$linkText"/>
</a>
(probably should be all one line...I separated to make it a little more
clear...)
By the way, you can put all of your javascript functions in a separate file
and include it (client-side) so you don't have to go through all the CDATA
or escaping of your functions for the XSL transfomation. You can do
something like this:
// &js_uri; is an entity that defines the path to the Javascript files
<script language="JavaScript" src="&js_uri;/scripts.js"></script>
> > I have an XSL sheet that constructs a simple table with links created
from a
> > set of ID's taken from the XML.
> > Creating the link is straighforward but I want to ensure that the link
is
> > opened in a new window with specific parameters. I know how to do this
in
> > Javascript using the code
> >
> > onClick="window.open('default.html','new','toolbars=no,scrollbars=no')
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list