Click here to Skip to main content
15,923,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my web application, I want to check wheather Javascript is enabled in the client browser or not. How to do it?

Thanks in advance
Updated 11-Feb-11 22:33pm

A bit of explanation to the Answer by Marcus: I may seem to be not really answering the question. Really, he did not provide the function IsJavascriptAllowed. But where such function should be called if it is not allowed? There is no such thing. So <noscript> is all you need.

Share this answer
Simple. Use the tag.

Check it out here NoScript Tag Info
Share this answer
Sergey Alexandrovich Kryukov 13-Feb-11 1:00am    
Good practical advice, my 5.
I added some explanation, please see. Trivial? Yes, very much. Still I feel for some it won't be immediately apparent form the first glance :-)
You can try the following markup side code.

<script type="text/javascript">
    function checkJavaScriptValidity()
        document.getElementById("Enabled").style.visibility = 'visible';
        document.getElementById("Disabled").style.visibility = 'hidden';

Write the function within the head tag.
Now call the function from body onload. like the following:

<body onload="checkJavaScriptValidity()">

And Now create two div(within the form tag) to show the message on your browser.Please follow the code below:

<div id="Enabled" style="visibility: hidden">
    Ya Browser JavaScript is enabled.have fun!!
<div id="Disabled">
    Browser JavaScript is disabled. Please Check the Browser Setting.

If you want to know that, the browser supports the javascript or not. You can use the following code:

if (Request.Browser.JavaScript)
Response.Write("Javascript Enabled") ;
Response.Write("Javascript Disabled") ;

If this would be really helpful to you then don't forgot to Vote and Make Answer as Accepted.
Share this answer
Ali Al Omairi(Abu AlHassan) 12-Feb-11 11:15am    
this is interisting,man. but i dont think the first code is neccesary where you can surrond the div "Disabled" with <noscript> tag.
Sandeep Mewara 13-Feb-11 1:07am    
Countered downvote. Looks good.
Manfred Rudolf Bihy 18-Feb-11 8:12am    
Agreed! 5+

In fact this is the only answer that deals with OP's question as Monjurul included code that can be used on the server side if the browswer supports JavaScript. OP asked specifically about checking in the web application which most certainly runs on the server side.
@Monjurul: Don't let that get you down though. Just keep up the good work and sooner or later you'll reap the benefits of your persistence. :thumbsup:
Monjurul Habib 21-Feb-11 14:01pm    
Thank you for the courage.
Have a look here[^], it would help. Few links like:
Similar link 1[^]
Similar link 2[^]
Share this answer
Sergey Alexandrovich Kryukov 13-Feb-11 0:59am    
Useful discussion, my 5.
Rounak Hasan 15-Feb-11 13:02pm    
Thanks.I have checked both links and used this one in my application.
<noscript><meta http-equiv="refresh" content="0; url=whatyouwant.html"></noscript>

This one is also very good.
<noscript> <style type="text/css"> .pagecontainer {display:none;} </style> <div class="noscriptmsg"> You don't have javascript enabled. Good luck with that. </div> </noscript>
Sandeep Mewara 15-Feb-11 13:03pm    
Glad to know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900