Click to See Complete Forum and Search --> : msxsl:script : JS runtime exception


mili
06-30-2004, 10:41 AM
I want to store a javascript variable in an xslt variable. I have a javascript function winName() (using msxsl:script) which has a variable called "winName".
This variable has a harcoded value called popup which I store in an xslt variable called temp. This works fine. But instead of hardcoding the winName in javascript,
I was trying to do: var winName = parent.window.name;
When I do this, I get the exception:
Error : Microsoft JScript runtime error 'document' is undefined line = 5, col = 6
(line is offset from the start of the script block). Error returned from property or method call

Can someone tell me what is wrong with my script?

Here is my code:

Thanks


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace">
<msxsl:script language='JavaScript' implements-prefix='user'>
function winName()
{
var winName = "popup";
return winName;
}
</msxsl:script>
<xsl:template match="/">
<html>
<head>
<title>untitled</title>

</head>
<body>
<xsl:variable name="temp" select="user:winName()"/>
<b>Window Name = <xsl:value-of select="$temp"/></b>

<br/>
</body>

</html>
</xsl:template>
</xsl:stylesheet>

Khalid Ali
06-30-2004, 11:30 PM
I don't understand your question completely,however it seems that you have a variable name and a function name same,which is problematic.
In myopinion,XSLT will be processed before document is created, hence javascript will never be able to transfer any data to xslt because when xslt is being processed JavaScript doesn't even exist.