“Please Enable JavaScript” Message
In this tutorial, i will show you how to simply display message when users don’t enable JavaScript on their browser. Why am i telling this for you? Look, it is 2009. Nowadays there are a lot of widgets, web services, and ads running under JavaScript manipulation. So, if your visitor disable JavaScript while browsing your pages, you must be missing a lot of advantages like:
- Advertisement
- Web Counter
- Web Stats
- Traffic Analytic
- AJAX animation, and so on…
So let’s get started and put the message on your page which will displayed when JavaScript is disabled and hidden when it is enabled. To do it so, you will need to use either simple <noscript> html tag or using JavaScript element hider.
-
Using NoScript HTML Tag
It is really a simple task to do. Just type your message inside <noscript> as usual and common HTML element. Code:
<noscript>Please enable your JavaScript for better view</noscript> -
Using JavaScript Element Hider
This method require both <script> and container tag like <div> , <p> , <span> , et cetera. First, make a message inside container with id = “js-disabled” and the code goes:
<div id = "js-disabled">Please enable your JavaScript for better view</div>
<script>
disabled = document.getElementById("js-disabled");
disabled.style.display = "none";
</script>
OK, that’s for the basic implementation.





