I am considering creating a website that only supports users with JavaScript enabled.
My justification for this is that I want to offer a rich user experience, in a fairly limited time budget, so if I only support people who have JS enabled, I don't have to spend time making sure the UI works without JS and create server side equivalents for validation etc.
Summary. Many Internet Web sites contain JavaScript, a scripting programming language that runs on the web browser to make specific features on the web page functional. If JavaScript has been disabled within your browser, the content or the functionality of the web page can be limited or unavailable.
After crunching the numbers, we found a consistent rate of JavaScript-disabled requests hovering around 1% of the actual visitor traffic, with the highest rate being roughly 2 percent in the United States and the lowest being roughly 0.25 percent in Brazil.
You might have heard that the percentage of users without JavaScript is approximately 1% and that these people actively turn it off. And on that basis that it's okay to exclude them. First of all, 1% of a large number is still a large number. A 1% increase in users is not usually something to be sniffed at.
Your justification is fine. However, you must implement validation on the server side of things as otherwise abusing your code will be very easy by just disabling JavaScript.
No, making it "impossible" to submit any data without JavaScript will not solve it.
From personal experience I think most internet users hava JS enabled nowadays. The portion of users who may have problems with JS-heavy site is mobile-based users, so unless you need to reach them, it probably should not be a big issue.
The easiest way to determine JS with just a single redirect would be to set a cookie with JavaScript code (document.cookie) and then use the aforementioned window.location to redirect. After that the server should be able to read the cookie set by JS, assuming it's enabled.
Also, while it's quite difficult to share validation rules and other logic automatically on both server and the client using tech like C#, I would suggest checking out Aptana Jaxer. Jaxer is a JavaScript based server-side framework which, amongst other things, will allow you to share the very same JavaScript code on both client and server. Very nice if you want to validate on the client, but don't want to write your validation rules twice!
See:
As for validation you should always do serverside validation and never rely on clientside validation. You're just asking to be hacked otherwise.
If you are doing a rich user experience and/or you don't have the time to do two (or more) versions of your Website to cater for such a small percentage, I think we've reached the time where that's usually acceptable.
It does however depend on the circumstances. Certain sites may target uses that disproportionately disable Javascript and so on.
You're missing a couple browser scenarios:
These days, the only people who don't use JS are usually:
In ASP.NET, or any HTML site, use:
<script type="text/javascript">
window.location="/hasJs.aspx";
</script>
Which will redirect them to a page for JavaScript users, which may set a cookie or something you can check for in your master page. Like so (or similar):
(in hasJs.aspx):
protected void Page_Load(object sender, object e) {
Response.Cookies.Add(new HttpCookie("hasJs", "yes"));
Response.Redirect("/Default.aspx");
}
(Site.master) :
<% if ( ! Request.Cookies.Contains("hasJs") ) { %>
<script type="text/javascript">
window.location="/hasJs.aspx";
</script>
This site requires JavaScript.
<% } %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With