This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How to get value from JavaScript
- From: "Kong, Yan" <KongY at corning dot com>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 03 Oct 2002 18:18:32 -0400
- Subject: [xsl] How to get value from JavaScript
- Reply-to: xsl-list at lists dot mulberrytech dot com
I need to get current URL and use the first part of the URL to other links.
I tried two ways but failed. Can anyone help me with this?
First, I tried to assign xslt variable using JavaScript:
*************************** XSLT codes *************************
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns:js="javascript:code" version = "1.1" >
<xsl:output method = "html" />
<xsl:variable name="url">
<script language="javascript">
var strID;
var intLen;
strID = window.document.location.toString();
intLen = strID.indexOf('livelink.exe/fetch');
strID = strID.substring(0, intLen);
document.write(strID);
</script>
</xsl:variable>
*************************** XSLT codes *************************
It consider all <script language="javascript">var strID; .....> as the variable.
Second, I tried to use JavaScript inside the <xsl:attribut> that belong to an anchor, error message said can't put it in the attribute.
*************************** XSLT codes *************************
<a>
<xsl:attribute name="href">
<script language='javascript'>
var strID;
var intLen;
strID = window.document.location.toString();
intLen = strID.indexOf('livelink.exe/fetch');
strID = strID.substring(0, intLen);
document.write(strID);
</script>
livelink.exe?func=ll&objID=<xsl:value-of select="@id"/>&objAction=View
</xsl:attribute>
<xsl:attribute name="target">_self</xsl:attribute>
<FONT SIZE="2" FACE="Arial,Helvetica,sans-serif">
<xsl:value-of select="@name" />
</FONT>
</a>
*************************** XSLT codes *************************
Javascript is used to get the first part of the current URL and pass it to other links.
Thanks,
Yan
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list