谁拥有的Javascript只支持用户启用 [英] Only supporting users who have Javascript enabled

查看:152
本文介绍了谁拥有的Javascript只支持用户启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑建立一个网站,只有支持JavaScript的用户启用。

我给这理由是,我想提供丰富的用户体验,在一个相当有限的时间预算,所以如果我只支持谁启用了JS的人,我没有花时间来确保用户界面不工作JS和验证等创建服务器端等价物。


  1. 这可能吗?做不同的浏览器\\平台prevent我从实现这一目标?

  2. 有多少比例的用户已经禁用了JS这些天?

  3. 我怎么会去,如果JS是在C#中启用了检查。


解决方案

您理由是罚款。但是,您必须实施对事物的服务器端验证,否则滥用你code将是刚刚禁用JavaScript的非常容易。

没有,使不可能提交没有JavaScript的任何数据都不会解决这个问题。

从个人的经验,我认为最使互联网用户HAVA JS时下。谁可能与JS-重现场问题的用户的部分是基于移动的用户,所以,除非你需要达到这些目标,它可能不应该是一个大问题。

确定只是一个单一的重定向JS最简单的方法是设置使用JavaScript code的cookie(的document.cookie),然后使用上述window.location的重定向。在此之后,服务器应该能够读取cookie被JS设置,假设它的启用。

此外,虽然这是相当困难的服务器和使用高科技,如C#在客户端上自动共享验证规则和其他逻辑,我建议检查出的Aptana Jaxer的。 Jaxer的是一个基于JavaScript的服务器端框架,除其他事项外,将让您共享客户端和服务器上的非常相同的JavaScript code。很不错的,如果你想验证在客户端上,但不想写你的验证规则的两倍!

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.

  1. Is this possible? Do different browsers\platforms prevent me from achieving this?
  2. What percentage of users have JS disabled these days?
  3. How would I go about checking if JS is enabled in C#.

解决方案

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!

这篇关于谁拥有的Javascript只支持用户启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆