in reply to Check for JavaScript Enabled

You can't. Imagine that you could. There's nothing to stop the visitor to your site to disable JS while your script is busy creating a page assuming that the browser has it enabled.

You'll have to send down a page with <SCRIPT> and <NOSCRIPT> tags.

If ever possible, make sure your site/page will work in both cases. If not possible in your case, let the <NOSCRIPT> tag indicate to your visitor that s/he must turn it on to visit and/or make use of your site/page.


Everything will go worng!

Replies are listed 'Best First'.
Re: Re: Check for JavaScript Enabled
by gellyfish (Monsignor) on Mar 04, 2002 at 12:07 UTC

    While i agree entirely that it is probably a silly idea to attempt this you can nonetheless do a test to see if JavaScript is enabled on any given page, although this is almost entirely a JavaScript thing. You can have something in your form like:

    <form name="my_form" method="POST" action="whatever.cgi"> <input type="hidden" name="got_js" value="0" /> <input type="submit" onClick="document.my_form.got_js.value = 1;" /> </form>
    And then in your CGI program you can check to see if got_js is 0 or 1. All of the other possible solutions are variations on this type of thing. But as Biker has pointed out it is probably a silly thing to do - I have only used this on entry to a site in order to provide an alternative to Javascript navigation thingies that the web-designer insisted on using TT2 to provide alternate content if got_js was false.

    /J\