Detecting if JavaScript is enabled in a browser
A project I am currently working on has just had an accessibility review performed by cFit and one of their suggestions was to cut down dependency on JavaScript or at least tell the users that the website requires it.
In ASP.Net you have a great feature to detect the "browser capabilities" and determine if it's a mobile browser, supports javascript etc.
Unfortunately this will only tell you IF the browser CAN support it and not if it is currently turned ON or OFF. As a result all versions of IE and Mozilla will always return YES to javascript even though the user may have turned JavaScript off.
When looking for a solution there were a number of options such as getting the browser to redirect using javascript on the page load and if the redirect works then you know its enabled etc.
As I only want to display a warning to the user to enable javascript I went for a low tech solution. Simply putting
<noscript>To use this site you must have Javascript enabled, please enable javascript to continue...</noscript>
In the master page will show a warning to non-javascript enabled users and nothing to everyone else.



0 Comments:
Post a Comment
<< Home