Show message if javascript disabled on client side using noscript tag

Trialcoder picture Trialcoder · Mar 5, 2013 · Viewed 56.3k times · Source

I want to flag a message if javascript is disabled at client side. I searched here and found <noscript> tag to use for handling this stuff.

I did this at w3schools editor to check but its not working let me know if this <noscript> is not meant for this or something else I am missing in this part ?

enter image description here

Answer

Rubyist picture Rubyist · Mar 5, 2013

Try This :-

How to detect JavaScript is disabled in browser?

As we know, tag is used for JavaScript. Same way there is tag which gets in action when the JavaScripts disabled in browser.

<script>Put Sample code here for execution when JavaScript is Active </script>
<noscript>Put Sample code here for execution when JavaScript is Disabled</noscript>

How to handle disabled JavaScript in browser?

When JavaScript is disabled, Just tried to redirect to some page where we can display the message that Javascript is disabled. There is meta tag in HTML named “meta refresh” which will redirect the user to another page in the interval specified in that header.

<noscript>
  <META HTTP-EQUIV="Refresh" CONTENT="0;URL=ShowErrorPage.html">
</noscript>

As, we can see above code inside noscript, there is “meta refresh” tag with interval of “0″ second. As, the JavaScript is disabled in that page, the browser gets redirected to “ShowErrorPage.html” to show some warning message.

I hope this will help you.