使用“return function()”调用函数 [英] calling function with "return function()"

查看:220
本文介绍了使用“return function()”调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Javascript the definitive guide的第392页一个函数被称为

,如下所示: -


< form action =" processform.cgi" onsubmit =" return validateForm();">


为什么,在这个例子中,是调用

函数validateForm时使用的return语句是否包含在功能中?


提前致谢,

On page 392 of "Javascript the definitive guide" a function is called
like this:-

<form action="processform.cgi" onsubmit="return validateForm();">

Why, in this instance, is the return statement used in calling the
function validateForm rather than being included inside the function?

Thanks in advance,

推荐答案

Steve< st ** *********@googlemail.comwrites:
Steve <st***********@googlemail.comwrites:

在Javascript the definitive guide的第392页上一个函数被称为

,如下所示: -


< form action =" processform.cgi" onsubmit =" return validateForm();">


为什么,在这个例子中,是调用

函数validateForm时使用的return语句比被包含在功能中?
On page 392 of "Javascript the definitive guide" a function is called
like this:-

<form action="processform.cgi" onsubmit="return validateForm();">

Why, in this instance, is the return statement used in calling the
function validateForm rather than being included inside the function?



因为onsubmit =" return validateForm();"大致相当于


element.onsubmit = function(){return validateForm(); };


while,onsubmit =" validateForm();"相当于


element.onsubmit = function(){validateForm(); };


另请注意,有直接相当于element.submit = validateForm;

-

Joost Diepenmaat |博客: http://joost.zeekat.nl/ |工作: http://zeekat.nl/

Because onsubmit="return validateForm();" is roughly equivalent to

element.onsubmit = function() { return validateForm(); };

While, onsubmit="validateForm();" would be equivalent to

element.onsubmit = function() { validateForm(); };

Also note that there is direct equivalent to element.submit = validateForm;
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Joost Diepenmaat< jo *** @ zeekat.nlwrites:
Joost Diepenmaat <jo***@zeekat.nlwrites:

另请注意,直接等效于element.submit = validateForm;
Also note that there is direct equivalent to element.submit = validateForm;



^^^^^^^^^我的意思是......没有直接......


-

Joost Diepenmaat |博客: http://joost.zeekat.nl/ |工作: http://zeekat.nl/

^^^^^^^^^ I meant "...is NO direct..."

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Joost Diepenmaat写道:
Joost Diepenmaat wrote:

Joost Diepenmaat< jo *** @ zeekat.nlwrites:
Joost Diepenmaat <jo***@zeekat.nlwrites:

>另请注意,有直接等价于element.submit = validateForm;
>Also note that there is direct equivalent to element.submit = validateForm;



^^^^^^^^^我的意思是......没有直接......

^^^^^^^^^ I meant "...is NO direct..."



有,但首先没有任何意义。如果它工作,你将

覆盖表单对象的submit()方法。

PointedEars

-

Prototype.js是由不懂javascript的人写的

谁不懂javascript。不知道javascript的人不是设计使用javascript的系统的最佳建议来源。

- Richard Cornford,cljs,< f8 ** *****************@news.demon.co.uk>

There is, but it makes no sense in the first place. If it worked, you would
be overwriting the form object''s submit() method.
PointedEars
--
Prototype.js was written by people who don''t know javascript for people
who don''t know javascript. People who don''t know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>


这篇关于使用“return function()”调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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