xslt - How to pass javascript variable to xsl variable? -


this has been asked before, want evaluate if possible?...

is there simple way pass javascript variable xsl variable? reason being, variable coming external script.

here's non-working code...

<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">      <xsl:template match="/">      <div>     <script type="text/javascript">     var key = window.location.href;     </script>      <xsl:variable name="jsvar">$key</xsl:variable>     <xsl:value-of select="$jsvar"/>      </div>       </xsl:template> 

i want display "term1" on web page.

any idea?

the script tag being output xsl, it's not defines that's executable in context of xsl. can define xsl variable @ global scope , re-use both in script , div:

<xsl:variable name="jsvar">term1</xsl:variable>  <xsl:template match="/">      <script>         var key = "<xsl:value-of select="$jsvar"/>";     </script>      <div>         <xsl:value-of select="$jsvar"/>     </div>  </xsl:template> 

if want variable known js when js executing , display in element in browser page, have in js:

<xsl:template match="/">      <script>         window.onload = function() {             document.getelementbyid('location').textcontent = window.location.href;         };     </script>      <div id="location"></div>  </xsl:template> 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -