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. User Avatar
    Toni Podmanicki
    Permalink to comment#

    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. User Avatar
    Permalink to comment#

    @Toni Podmanicki Thanks for the useful link

  3. User Avatar
    amit mojumder

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


    • User Avatar
      Permalink to comment#

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

  4. User Avatar
    Permalink to comment#

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

  5. User Avatar
    Permalink to comment#

    Thank you for this very useful snippet. :)

  6. User Avatar
    Prestashoop Indonesia

    Thanks for this one. Love this snippet

  7. User Avatar
    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. User Avatar
    Permalink to comment#

    Great job.. Thanks alot. -Steven

  9. User Avatar
    Permalink to comment#

    how would you delete any other content in the page?

Leave a Comment

Posting Code!

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.