1

Possible Duplicate:
Check if JavaScript is enabled with PHP

Is there some way to check on server if a visitor have disabled its javascript in browser ?

I know about client side ways I want to check it server, kindly guide.

Community
  • 1
  • 1
user576510
  • 5,777
  • 20
  • 81
  • 144
  • do something with javascript which reports "javascript enabled" to the server? – falstro Apr 19 '11 at 17:40
  • 1
    You shouldn't need to care if JS is on or off. Just build it right: http://icant.co.uk/articles/pragmatic-progressive-enhancement/ – Quentin Apr 19 '11 at 17:41

2 Answers2

2

You can't. You will have to somehow send a value back from the client to the server and deal with it appropriately.

One thing I thought of was on the login form, insert a hidden form field that says something like "JavaScriptEnabled". So when the user logins, you can set the session to know this information.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
0

If you're trying to do something like show a message if they don't have JavaScript, then show the message by default and remove it with JavaScript.

There might be a way of doing this by setting a session variable and then making an AJAX call - if you don't receive the AJAX call then you can guess that they don't have JavaScript but you won't know. They might just have a slow connection.

Finally, the other way is to do something like Google Maps and redirect the user to a page with a nojs=true variable in the URL. You disable the redirect with JavaScript, so it only happens if the user doesn't have JavaScript.

Dan Blows
  • 20,846
  • 10
  • 65
  • 96