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.")
</script>

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

Comments

  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="http://www.enable-javascript.com" 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?

    Thanks

    • 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 jimdo.de.

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

    dsg __

Leave a Comment

Posting Code

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
    ``` 
    <div>
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
    </div>
    ```
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

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