http://onionworks.net/2004/renderengine/utility

javaScriptEncode (orginal : string) : string

Similarly to the method “xmlEncode”, any string is changed into a compliant string here also, although this time for Javascript.

<xsl:variable name="var">Ist "das" \ein Test?</xsl:variable>
<script type="text/javascript">
<xsl:text>var someVar = "</xsl:text>
<xsl:value-of select="util:javaScriptEncode($var)" />
<xsl:text>";</xsl:text>
</script>
Filling variable Javascript in a compliant manner

The following call now takes place in the Javascript:
var someVar = "Ist das \"ein\" \\Test\?";