xsl-list
[Top] [All Lists]

[xsl] Onmouseover and onmouseout in xsl

2008-04-14 01:49:48
Morning, 

I am currently trying to embed an onmouseover event in my first XSL
sheet but am having difficulties in getting the event to work. 

Have I set the JavaScript up correctly in XSL? Also, is there a best
practice on embedding JS in XSLT - for instance is it best to link to an
external file (the same with CSS) and if so, what is the best way of
doing this?

Many thanks in advance for any help, 

Iain

The code that I have so far is:
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">

<html>
<head>
<style><xsl:comment>
h2 {
text-align: center;
font-family: Verdana;
}
td {
  font-family: Arial;
  text-align: left;
}

</xsl:comment>
</style>
<script type="text/javascript">
<![CDATA[

var newWindow;

function newWindow {
        if(!newWindow || newWindow.closed) {
        newWindow = window.open("test.html","sub", "status,height=200,
width=300");
        //delay writing whilst Windows catches up
        setTimeout("writetoWindow()", 50);
} else if (newWindow.focus) {
        //new Window is already open so bring to front
        newWindow.focus();
        }
}//end newWindow
function writetoWindow() {
        var newContent = "<html><body><p>Hello World!</p></body</html>";
        newWindow.document.write(newContent);
        newWindow.document.close();
}
function close() {
        newWindow.close();
        
}

]]>
</script>
<title>Charles Dickens</title>
</head>
<body>
<table name="Charles Dickens">
<tr>
<td colspan="3">
<h2>Charles Dickens</h2>
</td>
</tr>
<xsl:for-each select="dickens/text">
<tr>
<td>
<xsl:attribute name="onmouseover">newWindow()</xsl:attribute>
<xsl:attribute name="onmouseout">close()</xsl:attribute>
Diffs
</td>
<td><strong><xsl:value-of select="lineno"/></strong></td>
<td><xsl:value-of select="line"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] Onmouseover and onmouseout in xsl, Emsley, I (Iain) <=