Search code examples
javascripthtmlprototypejs

How can I detect whether JavaScript is disabled using prototype?


How can I detect whether JavaScript is disabled using the prototype library? I don't want to use the <noscript> tag; I want to use something that prototype offers.


Solution

  • It would be pretty hard to use javascript to detect if javascript is disabled.

    To answer your subquestion, if you want to emulate <noscript> tag behavior without using noscript, make a <div> element with the content you want to show to non-javascript users, and then hide it with javascript on DOMReady event. It will do exactly the same thing as a noscript tag.

    <script type="Text/JavaScript">
    document.observe("dom:loaded", function() {
      $('simulate_noscript').hide();
    });
    </script>
    
    <div id="simulate_noscript">
    This is some content only users with JS disabled will see.
    </div>