Page 1 of 1

Is active content enabled

Posted: Thu Aug 24, 2006 4:28 pm
by lex
This should be a Mickey Mouse question.

I want to write alternative code if active content is disabled.

Something along these lines:-

{* smarty code snippet *}
<a href="{if $activeContentIsEnabled == 1}javascript:myscript(){else}stuff{/if}">stuff</a>

But I can't find out how to detect if the user's browser has active content enabled. All my googling shows me is hundreds of pages telling me how to turn it on in IE, Mozilla..., or why it should be turned off.

how do I set the value to my variable $activeContentIsEnabled?

Posted: Thu Aug 24, 2006 6:24 pm
by Christopher
Google "browser sniffer" and see if you find anything to help.

Posted: Thu Aug 24, 2006 9:22 pm
by alex.barylski
By active content I assume you mean active scripting...which is javascript in IE terms...

You can't detect whether javascript is disabled because you would need javascript to do that...

So instead you use the <noscript> tag which is rendered *only* when javascript is turned off...

Posted: Thu Aug 24, 2006 9:51 pm
by Jenk
or you can get crafty.

Code: Select all

<script language="JavaScript">
function mySubmit ()
{
    var form = document.getElementById('myForm');
    form.action = form.action + '?js=true';
    form.submit();
}
</script>
<form name="myForm" action="index.php" method="post">
<input type="text" name="text" size="10" />
<input type="submit" onclick="mySubmit();return false;" />
</form>