views:

94

answers:

5

How to find whether user has enabled or disabled javascript of the browser or the bowser do not support javascript.

A: 

There isn't really a stable way, but you could do something like having Javascript send a message to your server which will set a flag there. If the message is not sent, you know Javascript is disabled.

Bart van Heukelom
Why the downvote? It's the same as the accepted answer, but without specifics explained (which doesn't make it less valid). Meh...
Bart van Heukelom
+1  A: 

You can a <script> tag to that sends users to a page that uses Javascript.

For example: (in your <head>)

<script type="text/javascript">
    location.replace("JavaScript-Enabled.aspx");
</script>

However, the proper way to handle this is to allow your pages to work both with and without Javascript.

SLaks
Why was this downvoted?
SLaks
@SLaks - no clue! +1
LeguRi
@SLaks I think it was downvoted, because it's no answer to the question. You assume, the question was asked, because the asker want's to do something like you suggested in your answer, but that's only an assumption. Your workaround is no real answer to the question.
bitschnau
+2  A: 

There is no way, but it shouldn't concern you.

Design your pages so they work properly without any javascript. When you're done, add unobtrousive javascript that will "override" links or submits behaviour so the js enabled users will get the nice js features, and for those with no js support the site will nicely degrade to the standard features.

Matteo Mosca
what about gmail .if javascript is disbled it prompts user to enalbe it use htmlview.
Niraj Choubey
That's different. It uses the <noscript> tag to prompt content only if JS is not enabled, but that information doesn't reach their servers.
Matteo Mosca
+2  A: 

There is not really a reliable way to do this. Besides it's up to the user of the browser to enable javascript or not. Try to make your site in such a way that it downgrades gracefully to a state where it doesn't have to support javascript but still can have the most important functionality.

Html also provides the < noscript> element in which you could state to the user that (s)he could turn on javascript to have a better experience. But still it's up to him/her to do so.

XIII
+3  A: 

Actually this is no direct way to detect javascript enable/disable. Go through below article explain how to detact javascript enable or disable

Detect if JavaScript is enabled in ASPX

Pranay Rana
Thanks pranay, but how to find if browser supports javascript or not.
Niraj Choubey
For the answer to that question see...this answer.
Bart van Heukelom