Setting a variable if javascript is enabled?
| From: | Matthias Mohr | Date: | Wed, 12 Feb 2003 12:46:26 +0000 |
| Subject: | Setting a variable if javascript is enabled? | ||
| References: | 1 2 3 4 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7672@lists.php.net to get a copy of this message | ||
I need to detect in my Smarty-Templates if the browser has javascript enabled or not.
If javascript is enabled, I can insert javascript-variables; otherwise not.
I try to do something like that (smarty-delimiter are changed to "<{" and
"}>"):
--------------------------------------------------------
<SCRIPT>
<{assign var="_jsenabled" value="1"}>
var mydisp = "display:none"
</SCRIPT>
...
<UL id="name" style=<{if $_jsenabled eq
""}>&{mydisp};<{else}>"display:block;"<{/if}>>
...
--------------------------------------------------------
So I try to write
style=&{mydisp};
when javascript is enabled and
style="display:block;"
when javascript is disabled.
Of course it doesn't work (Smarty will parse the script and always set _jsenabled to
"1" - right?)
But what else can I do to detect either in PHP or in Smarty if Javascript is enabled or not?
with regards,
Matthias