I need to make a fork (depending on javascript enabled or not):
<?xml version="1.0" encoding="windows-1251"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="no" encoding="windows-1251"/>
<xsl:template match="someNode">
<xsl:variable name="vNoscript">
<noscript>true</noscript>
</xsl:variable>
<xsl:choose>
<!-- javascript disabled -->
<xsl:when test="$vNoscript = 'true'">
code branch 1
</xsl:when>
<!-- javascript enabled -->
<xsl:otherwise>
code branch 2
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
This code is not working properly – the variable “vNoscript” in any case contains the value “true”.
What are some ways to solve the problem?
May be necessary to do such tests very differently?
Update 1: I run this code on server.
Update 2: I need to dynamically load the pictures on page (using javascript). For those who have disabled Javascript in browser I need to upload pictures “in the usual way.”
Since you are running this code on the server you can’t know whether the client has JavaScript enabled or not.
One way to circumvent this problem is by using an HTTP request parameter telling you whether to generate a JavaScript-enabled version of your page or not and the client decides which version to call:
Then you either call separate XSL transformations, or you can use a single, parameterized XLST.
Update (after your edit):
Simply create
noscriptcontent in your XSLT as you would do in static HTML: