从单个事件调用多个函数 [英] calling multiple functions from a single event

查看:80
本文介绍了从单个事件调用多个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我试图通过

锚标记上的1 onMouseOver事件调用2个函数,但我似乎无法理解让它工作。以下应该

演示


< a onMouseOver =" ShowMenu(''Menu3''); AddMenuToHoldArray(''Menu3'')" >菜单

3< / a>

我尝试过多种变体,例如添加javascript :在第一次调用前面的
,并从第一个

函数返回False,但Icant在第一个
$ b之后获得第二个函数$ b一个人。


通过使用警报,并观察发生的事情,我知道第一个

被调用,但第二个不是'' t。


几年前我做过这个,但我似乎无法重述我的表现,

它,没有一个例子我找到了帮助,所以可以

有人指出我正确的方向吗?


谢谢

解决方案

文章< a8 ****************************** @ news .teranews.co m>,
re ************ @ hotmail.com 启发我们......


几年前我做过这个,但我似乎无法重述我的做法,
它,我所找到的例子都没有帮助,所以ca n
有人指出我正确的方向吗?



我没有看到你调用函数的方式有什么问题,

但是如果AddMenuToHoldArray中有任何错误,该函数不会做任何事情。您是否尝试将其中的一个单独放在鼠标悬停中

以查看它是否有效?


此外,javascript区分大小写 - 是正确的情况以这个名字?


您也可以尝试使用Netscape 7 - 他们有更好的调试器。在NN中将您的页面带上

,然后输入javascript :在

之后的位置栏中,您尝试了代码并且函数没有被调用。如果有一个

错误,它将显示在控制台中。


除此之外,我还需要查看代码。


----------------------------------------- --------

~kaeli~

耶稣拯救,真主保护,和克苏鲁

认为你会做一个漂亮的三明治。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
--------------------------------------------- ----


我知道第二个功能没问题,它甚至从未输入过
。为了测试它是否被输入,我在

开始时放置了一个alert(),当sedond函数是该事件的唯一函数

时它运行,但是如果有2个功能则不行。


我假设问题出在某个地方,因为返回

值或某些等等,第二个功能是被完全忽略

2003年10月28日星期二07:20:00 -0600,kaeli

< in ************* *******@NOSPAMatt.net>写道:

在文章< a8 ****************************** @ news.teranews.co m>,
re************@hotmail.com启发我们...


我这样做了几年前,但我似乎无法重述我的表现,
它,我所找到的例子都没有帮助,所以任何人都能指出我正确的方向吗?



我没有看到你调用函数的方式有什么问题,
但是如果AddMenuToHoldArray中有任何错误,那么函数就不会做什么的。您是否尝试将其中的一个单独放在鼠标悬停中
以查看它是否有效?

此外,javascript区分大小写 - 该名称的大小写是正确的吗?

您也可以尝试使用Netscape 7 - 它们有更好的调试器。在NN中显示您的页面,然后输入javascript :在
之后的位置栏中,您尝试了代码并且函数没有被调用。如果出现
错误,它将显示在控制台中。

除此之外,我还需要查看代码。

--- ----------------------------------------------
〜kaeli~
耶稣拯救,真主保护,而Cthulhu认为你会做一个漂亮的三明治。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
----------------------- --------------------------




< ;再************ @ hotmail.com>在消息中写道

news:c8 ****************************** @ news.teranew s。 com ...

< snip>

我认为问题出在某处,因为
返回值或某些等等,第二个函数是被完全忽略




您发布的属性代码在语法上是正确的,并且应该

导致两个函数被调用。第一个

函数的返回值对第二个函数

的执行没有影响,因为事件处理代码正在丢弃它。但是你认为它可能会产生影响的事实表明你没有资格判断你给出的建议。所以,要重新说明

凯利的建议: -


1.检查函数的情况(也许是拼写)

调用与

函数定义中的标识符完全对应。

2.确定是否有任何错误消息(以及,如果是,哪些)是

正在生成。

3.发布正在调用的函数的代码。


Richard。


Hi All,

I am trying to call 2 functions from the 1 onMouseOver event on an
anchor tag, but I can''t seem to get it to work. the following should
demonstrate

<a onMouseOver="ShowMenu(''Menu3'');AddMenuToHoldArray( ''Menu3'')">Menu
3</a>
I have tried a number of variations, like adding "javascript:" in
front of the first call, and returning True of False from the first
function, but Icant get the second function to fire after the first
one has.

by using alerts, and wathcing what IS occuring, I know that the first
is being called, but the second isn''t.

I did this once some years back, but I can''t seem to rember how I did,
it, and none of the example that I have located have helped, so can
anyone point me in the right direction?

thanks

解决方案

In article <a8******************************@news.teranews.co m>,
re************@hotmail.com enlightened us with...


I did this once some years back, but I can''t seem to rember how I did,
it, and none of the example that I have located have helped, so can
anyone point me in the right direction?


I don''t see anything wrong with the way you''re calling the functions,
but if there is any error in AddMenuToHoldArray, the function won''t do
anything. Did you try just putting that one in the mouseover by itself
to see if it works?

Also, javascript is case-sensitive - is the case correct in that name?

You can also try using Netscape 7 - they have a better debugger. Bring
up your page in NN, then type "javascript:" in the location bar after
you try the code and the function doesn''t get called. If there was an
error, it will show up in the console.

Other than that, I''d need to see code.

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you''d make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------


I know that the second function is ok, an that it is never even being
entered. To test that it was being entered I placed an alert() at the
start of it, and it runs when the sedond function is the only function
on the event, but not if there are 2 functions.

I assume the problem lies somewhere in the fact that due to return
values or some such, the second function is being ignored completely
On Tue, 28 Oct 2003 07:20:00 -0600, kaeli
<in********************@NOSPAMatt.net> wrote:

In article <a8******************************@news.teranews.co m>,
re************@hotmail.com enlightened us with...


I did this once some years back, but I can''t seem to rember how I did,
it, and none of the example that I have located have helped, so can
anyone point me in the right direction?


I don''t see anything wrong with the way you''re calling the functions,
but if there is any error in AddMenuToHoldArray, the function won''t do
anything. Did you try just putting that one in the mouseover by itself
to see if it works?

Also, javascript is case-sensitive - is the case correct in that name?

You can also try using Netscape 7 - they have a better debugger. Bring
up your page in NN, then type "javascript:" in the location bar after
you try the code and the function doesn''t get called. If there was an
error, it will show up in the console.

Other than that, I''d need to see code.

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you''d make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------




<re************@hotmail.com> wrote in message
news:c8******************************@news.teranew s.com...
<snip>

I assume the problem lies somewhere in the fact that due to
return values or some such, the second function is being
ignored completely



The attribute code that you posted is syntactically correct and should
result in both functions being called. The return value of the first
function will have no influence on the execution of the second function
as it is just being discarded by the event handling code. But the fact
that you think it may have an influence demonstrates that you are not
qualified to judge the advice that you have been given. So, to re-state
Kaeli''s advice:-

1. Check that the case (and maybe spelling) of the function
calls corresponds exactly with the identifiers in the
function definitions.
2. Determine if any error messages (and, if so, which) are
being generated.
3. Post the code of the functions that are being called.

Richard.


这篇关于从单个事件调用多个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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