Require javascript - can it be applied through server language

I developed ajax framework using php / jQuery etc. I would like the user to โ€œrequireโ€ the user to enable javascript to use the application (they are all internal applications, so we can dictate compatibility).

How can I determine if javascript is enabled on the server? please provide an example.

0
javascript cross-browser php
source share
5 answers

You cannot detect this server side, however you can present the client side of the message with the <noscript> , for example:

 <noscript> <div class="alert">You need to enable JavaScript to use this site.</div> </noscript> 
Tags

<noscript> appear when the client does not have a default JavaScript feature, so use them to present them with a message, element, etc., just give it some styles, and you're good to go.

+6
source share

You can not. You will need to run it on the client, then ask him to either go to a specific URL or contact the server via AJAX to notify him.

+2
source share

Never do this, but consider this web service script, reductio ad absurdum:

  • Suppose js is disabled and prints non-js content
  • register ajax request only if js is active, which will pass the token to the listener server
  • if the listener receives a message in the resonant timeframe, returns new content and changes the non-js content with it

This way you are covered in both scenarios. Another approach is regular with startup, assuming js is enabled. By the way, I think that about 90% of web users have js, perhaps even more.

+1
source share

After some creative thinking ... I think I'm going to go with this solution, but I would like to get some feedback.

Set a cookie with JS to load the page - determine if it is there on the server side


For me, this seems viable because it is very lightweight and suitable for my application structure. The idea of โ€‹โ€‹deviating from my ajax call structure bothers me.

+1
source share

Just do it on the client side. If javascript is enabled, it is redirected to a good site, otherwise it displays a simple html page with an error message.

0
source share

All Articles