Is there a way to test to see if javascript is enabled to ensure an application that required javascript is not initiated when it is disabled or otherwise not available?
-
possible duplicate of How to detect if JavaScript is disabled?Mike Weller– Mike Weller2013年04月05日 13:51:42 +00:00Commented Apr 5, 2013 at 13:51
6 Answers 6
There is <noscript>.
2 Comments
I tend to use the following way.
1) show an error message per default
<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 app's container
$("#noJS").hide();
$("#app").show();
If javascript is only needed for e.g. navigation, you should try to deliver a non-js version for non-js users in order to increase your audience.
4 Comments
By default, serve the no-Javascript version. Use Javascript to immediately redirect the user to the Javascript version (which will only work if Javascript is enabled).
Comments
The scenario is:
- Visitor makes first request to your site
- Deliver a page which sets two cookiesl one with javascript, another with your server side language.
- Header or Meta redirect to another page for testing.
- On test page, check if you received the server delivered cookie to see if cookie support is enabled, and test if javascript cookie was received for JS support enabled.
- Enjoy your new found knowledge.
Comments
Not on initial load. You can try to use tricks like setting a cookie in JavaScript and check it on subsequent requests. The best way is to ensure that your site works without JavaScript, and use JavaScript to provide a better experience.
You could create a page with <noscript> content, and have that redirect using javascript to your actual application