If I have a website that makes use of javascript and the user will get the most full experience of the website if they have javascript enabled, but it would still be fully functional even if javascript was disabled. Is there a way to check if the user has javascript disabled for the browser they are using, so I can display a message of something like: "The website is best viewed with javascript enabled"
5 Answers
You could use the <noscript> tag:
<noscript>
The website is best viewed with javascript enabled
</noscript>
You may also take a look at this article about unobtrusive javascript.
Comments
Check the <noscript> HTML-Tag
The proper way to do this is to use Progressive Enhancement. Have a basic markup file that will work across all browsers. Then apply your JavaScript to browsers that understand JS emitted by a test suite:
Comments
In ASP.Net we have Request.Browser.JavaScript in order to check whether browser support Javascript or not not but it does not check whether disable or enable.
There is an article on codeproject.com describing a work around for same purpose. You can check it out at http://www.codeproject.com/KB/aspnet/Detect_JavaScript_in_ASPX.aspx.
<noscript>isn't part of xhtml5 anymore since it doesn't play well with DOM.