Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > How to call event as a function in mozilla

Reply
Thread Tools

How to call event as a function in mozilla

 
 
Jadow
Guest
Posts: n/a
 
      07-07-2003
I have a function that is used as an event for some parts of the
script.
i.e.
function somethind(e) {
if (!e.currentTarget.documentElement ){
...
}
}

I need to call this function manually (not by assigning it to an
event) Yet I cannot seem to deal with 'e'.
If I call it as: something(e); I get a 'not defined', if I ommit it I
get an undefined.
For some reason 'e' is undefined in the calling script. What decides
when it is available as an event object? and how can I resolve this
issue?

Thanks
Joshua
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      07-07-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (Jadow) writes:

> I have a function that is used as an event for some parts of the
> script.


It is an event handler. The "e" will be the event then.

> function somethind(e) {
> if (!e.currentTarget.documentElement ){
> ...
> }
> }


That requires the currentTarget property to be a document object.

> I need to call this function manually (not by assigning it to an
> event) Yet I cannot seem to deal with 'e'.
> If I call it as: something(e); I get a 'not defined', if I ommit it I
> get an undefined.


If you write
something(e);
and "e" is not a defined variable, then it is ofcourse an error. You have
to add an event as argument (or any object with a currentTarget property).
Try
something({currentTarget:document});

> For some reason 'e' is undefined in the calling script.


That reason is proabably that it hasn't been defined.

> What decides when it is available as an event object?


When you assign it. The "e" in the function definition only
exists inside the function. It is a local name for the argument
to the function.

/L
--
Lasse Reichstein Nielsen - (E-Mail Removed)
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to call function whose function call with arguments is in astring Options grbgooglefan C Programming 4 01-30-2008 05:12 PM
How to call function whose function call with arguments is in astring grbgooglefan C++ 2 01-30-2008 07:18 AM
How to call function whose function call with arguments is in astring Options grbgooglefan C Programming 0 01-30-2008 04:19 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM



Advertisments