Testing if javascript is enabled

Is there a way to check if javascript is allowed to ensure that an application that requires javascript to not start when it is disabled or otherwise inaccessible?

+7
javascript
source share
6 answers

I tend to use the following method.

1) displays a default error message

<div id="noJS">For use, you need JavaScript enabled. (nice images and perhaps a link to your fav. browser)</div> 

2) disable it via javascript and show the main application container

 $("#noJS").hide(); $("#app").show(); 

If javascript is only needed for, for example, navigation, you should try to provide a non-js version for non-js users to increase your audience.

+5
source share

There is <noscript> .

+6
source share

By default, use a version without JavaScript. Use Javascript to immediately redirect the user to a version of Javascript (which will only work if Javascript is enabled).

+3
source share

Scenario:

  • The visitor makes the first request to your site.
  • Provide a page that sets two cookies with javascript, the other with your server side language.
  • Redirecting a title or meta to another page for testing.
  • On the test page, check if the server received the cookie with the server delivery to make sure cookie support is enabled, and check if the javascript cookie was received to support JS.
  • Enjoy the new knowledge.
+2
source share

Not at boot time. You can try using tricks, for example, setting a cookie in JavaScript and checking it on subsequent requests. The best way is to ensure that your site runs without JavaScript, and use JavaScript for a better experience.

0
source share

You can create a page with <noscript> content and redirect it using javascript to your actual application

0
source share

All Articles