How to determine whether Javascript is enabled?

There are a lot of approaches to this. Lets take them one at a time:

  • Using NOSCRIPT tag: You can write a noscript tag just before your script tag to display the user a warning message. Check the code below, wherein the user will be redirected to another page if javascript is disabled:


<noscript><meta http-equiv=”refresh” content=”0; url=whatyouwant.html”></noscript>

<!–this javascript ensures that anybody that doesnt use javascript wont see the menu–>
<script type=”text/javascript”>
<!–hide script from older browsers
document.write(‘<select name=”whatever”><option>1</option><option>2</option></select>’);

  • Check out this interesting article on 15 seconds,  Creating a Server Control for JavaScript Testing by George Masselli. It explains how to create a control that verifies whether Javascript is supported and enabled. Apparently it is not easy to determine if a user disabled Javascript support for security reasons.
  • A simple concept of hiding the always visible warning message through javascript. In this case, if your browser has javascript enabled, the script will hide the message. However, if it has javascript disabled, the message will be visible always. Check the snippet below:

<body onload=”valid()”>
<form id=”form1″ runat=”server”>
<label Id=”lblWarning”>Your Browser has Disabled Scripting</label>
<script type=”text/jscript”>
function valid()
var lbl=document.getElementById(‘lblWarning’); = ‘none’;


Hope this was useful. Feel free to add on more options.

  1. This is working fine tested.Great Idea.


Feel free to leave a reply here...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: