Grow your CSS skills. Land your dream job.

Last updated on:

Detect Javascript On/Off, With Notification

<script type="text/javascript">
   document.write("Welcome, you have Javascript on.")

<noscript>JavaScript is off. Please enable to view full site.</noscript>

If JavaScript is on the user gets a welcome message. If off, the user is instructed to turn it on.


  1. You could also simply add a link with instructions on how to turn on JavaScript in the noscript tag.

    <noscript>For full functionality of this page it is necessary to enable JavaScript. Here are the <a href="" target="_blank"> instructions how to enable JavaScript in your web browser</a></noscript>

  2. Mani
    Permalink to comment#

    @Toni Podmanicki Thanks for the useful link

  3. amit mojumder

    Nice snippet. Thanks for sharing.
    But, isnt it supposed to show the notification on a pop up instead of site upper header?


    • Domenic
      Permalink to comment#

      That would require Javascript, which if the reader has it disabled then you can’t give an alert like that.

  4. Permalink to comment#

    I think it’s better in this way. An in-page message could be less annoying than a popup.

  5. Permalink to comment#

    Thank you for this very useful snippet. :)

  6. Thanks for this one. Love this snippet

  7. Permalink to comment#

    It doesn’t work if your site is at

    My script for my site:

    document.getElementById(“JavaS”).innerHTML = “Welcome, you have Javascript on.”;

    For full functionality of this page it is necessary to enable JavaScript. Here are the instructions how to enable JavaScript in your web browser.

  8. Steven
    Permalink to comment#

    Great job.. Thanks alot. -Steven

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like ```this```. You don't need to escape code in backticks, Markdown does that for you.

Sadly, it's kind of broken. WordPress only accepts a subset of HTML in comments, which makes sense, because certainly some HTML can't be allowed, like <script> tags. But this stripping happens before the comment is processed by Markdown (via Jetpack). It seems to me that would be reversed, because after Markdown processes code in backticks, it's escaped, thus safe. If you think you can fix this issue, get in touch!

If you need to make sure the code (typically HTML) you post absolutely posts correctly, escape it and put it within <pre><code> tags.

Current ye@r *

*May or may not contain any actual "CSS" or "Tricks".