Is active content enabled

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lex
Forum Newbie
Posts: 4
Joined: Tue Jul 11, 2006 11:00 am

Is active content enabled

Post 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Google "browser sniffer" and see if you find anything to help.
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post 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...
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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>
Post Reply