How to call event as a function in mozilla

J

Jadow

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
 
L

Lasse Reichstein Nielsen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top