开发者

how to check on server if javascript is disabled? [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

Check if JavaScript is en开发者_运维知识库abled 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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜