我们可以知道用户是否有js? [英] can we know if the user has js on?

查看:73
本文介绍了我们可以知道用户是否有js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法知道用户是否有javascript?另外,在js和php中验证所有输入是否是一个好主意?或者这会减慢

网站吗?

Is there a way to know if the user has javascript on? Also, is it a
good idea to validate all input in js and php or will this slow down
the website?

推荐答案

要测试javascript是否已被设置,请尝试使用以下链接:

starters:

http://www.google.com/search?q = test%... ript%20enabled


根据经验,总是在服务器端验证表单数据(php)。

在客户端验证是只有当你给用户一个快速的

错误信息告诉他们输入不完整或不正确时才有用。

这只是为了让他们不要必须等待往返于服务器的

才能发现他们忘记了一个字段。

11月30日下午6:27,Ken1 < ken ... @ gmail.comwrote:
To test if javascript is enbabled, try some of these links for
starters:

http://www.google.com/search?q=test%...ript%20enabled

As a rule of thumb, always validate form data on the server side (php).
Validating at the client is only helpful if you give the user a quick
error message telling them their input is not complete or incorrect.
It''s just to so that they don''t have to wait for the round trip from
the server to find out they forgot a field.
On Nov 30, 6:27 pm, "Ken1" <ken...@gmail.comwrote:

有没有办法知道用户是否有javascript?另外,在js和php中验证所有输入是否是一个好主意?或者这会减慢这个网站的价值吗?
Is there a way to know if the user has javascript on? Also, is it a
good idea to validate all input in js and php or will this slow down
the website?




Ken1写道:

Ken1 wrote:

有没有办法要知道用户是否有javascript?
Is there a way to know if the user has javascript on?



< form ...>

....

< noscript>

< input type =" hidden"名称= QUOT; NoScript的" value =" true">

< / noscript>

....

< / form>

<form ...>
....
<noscript>
<input type="hidden" name="NoScript" value="true">
</noscript>
....
</form>


另外,在js和php中验证所有输入是否是个好主意或者这会慢下来

网站?
Also, is it a
good idea to validate all input in js and php or will this slow down
the website?



拥有它是一个非常好的主意。相信它是非常糟糕的主意。 :-)

It is a very good idea to have it. It is very bad idea to trust it. :-)


VK在11/30/2006 11:26 PM说:以下内容:
VK said the following on 11/30/2006 11:26 PM:

Ken1写道:
Ken1 wrote:

>有没有办法知道用户是否有javascript?
>Is there a way to know if the user has javascript on?



< form ...>

...

< noscript>

< input type =" hidden"名称= QUOT; NoScript的" value =" true">

< / noscript>

...

< / form>


<form ...>
...
<noscript>
<input type="hidden" name="NoScript" value="true">
</noscript>
...
</form>



只要你不介意无效的HTML及其带来的后果

吧。

-

兰迪

机会有利于预备心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/

As long as you don''t mind invalid HTML and the consequences that come
from it.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


这篇关于我们可以知道用户是否有js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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