Skip to content

Is JavaScript enabled | HTML Example code to Check

  • by

How to detect if JavaScript is disabled?

You can use <noscript> and <meta> tag to check JavaScript enabled. The noscript blocks are executed when JavaScript is disabled. It’s typically used to display alternative content that you’ve generated in JavaScript,

  <meta http-equiv=refresh content='0; url=http://your.domain/noscript'>

Note: It’s not give 100% accurate result, There is not a good way to perform server-side JavaScript detection.

Example of Check If JavaScript Is Enabled

Here is worked code: it redirects a visitor if JavaScript is disabled, example in HTML.

<!DOCTYPE html>
    <meta http-equiv="refresh" content="1;url=error.html">



Output: If JavaScript enabled then it will not redirect error webpage.

If you want a purely statistical idea of how many of your users have JavaScript disabled, you could do something like:

    <img src="no_js.gif" alt="Javascript not enabled" />

Do comment if you are facing any issue or have any suggestions on this tutorial.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *