Reputation: 21935
I have developed an ajax application framework using php/jQuery etc. I would like to 'require' a user to have javascript enabled in order use the application (they are all internal apps so we are able to dictate the compatibility).
How can I detect if javascript is enabled on the serverside? please provide an example.
Upvotes: 0
Views: 624
Reputation: 21935
Upon some creative thinking... I think I am going to go with this solution - but I'd like feedback.
To me this seems viable because it's super light-weight and it fits my application structure nicely. The idea of straying from my ajax call structure bothers me.
Upvotes: 1
Reputation: 27876
Never done this but consider this webservice scenario, reductio ad absurdum:
This way you are covered for both scenarios. Another approach is the regular one with starts with the assumption that js is enabled. By the way,I guess about 90 % of webuser have js enabled, maybe even more.
Upvotes: 1
Reputation: 2811
Just do it on the client side. If javascript is on it redirects to good site, else it display simple html page with error message.
Upvotes: 0
Reputation: 630549
You can't detect this server-side, you can however present a message client-side with the <noscript>
tag, like this:
<noscript>
<div class="alert">You need to enable JavaScript to use this site.</div>
</noscript>
<noscript>
tags appear when the client doesn't have JavaScript enabled for whatever reason, so use them to present a message, element, etc to them...just give it some styling and you're good to go.
Upvotes: 6
Reputation: 798944
You can't. You will need to run it on the client, then have it either go to a specific URL, or contact the server via AJAX to notify it.
Upvotes: 2