The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

Detect Javascript On/Off, With Notification

Last updated on:
<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. 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. 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. Sherton
    Permalink to comment#

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

  5. Luanne
    Permalink to comment#

    Thank you for this very useful snippet. :)

  6. Prestashoop Indonesia

    Thanks for this one. Love this snippet

  7. LS76
    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

  9. Dan
    Permalink to comment#

    how would you delete any other content in the page?

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed