471,119 Members | 1,109 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

FireFox window.event


Hi

In IE there seem to be a global variable window.event, holding the current
event....however this dowsn't work in FireFox... is there a similar way to
get the current event??

TIA

Søren
Jul 23 '05 #1
3 27031


Søren M. Olesen wrote:

In IE there seem to be a global variable window.event, holding the current
event....however this dowsn't work in FireFox... is there a similar way to
get the current event??


Event handlers have a parameter, in event handler attributes you can use
event
e.g.
<input type="button" onclick="alert(event.type);">
if you use script to set
element.oneventname
then you can choose the parameter name yourself e.g.
element.onclick = function (evt) {
alert(evt.type);
};
Of course for IE you need to continue to use window.event so you end up with
element.onclick = function (evt) {
if (!evt && window.event) {
evt = window.event;
}
if (evt) {
alett(evt.type);
}
};

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Hi Martin

Thanks for your reply, however my problem is that my function is called from
some code that I didn't write (code from Infragistics), and they don't send
the event as a parameter, so I really looking for some other way to get hold
of the event...something like window.event

Regards,

Søren

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:41***********************@newsread4.arcor-online.net...


Søren M. Olesen wrote:

In IE there seem to be a global variable window.event, holding the
current event....however this dowsn't work in FireFox... is there a
similar way to get the current event??


Event handlers have a parameter, in event handler attributes you can use
event
e.g.
<input type="button" onclick="alert(event.type);">
if you use script to set
element.oneventname
then you can choose the parameter name yourself e.g.
element.onclick = function (evt) {
alert(evt.type);
};
Of course for IE you need to continue to use window.event so you end up
with
element.onclick = function (evt) {
if (!evt && window.event) {
evt = window.event;
}
if (evt) {
alett(evt.type);
}
};

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #3
On Mon, 6 Dec 2004 07:07:35 +0100, Søren M. Olesen <sm******@hotmail.com>
wrote:
[...] I really looking for some other way to get hold of the
event...something like window.event


You can't. The standardised event model only provides the event object as
an argument to the event listener. You'll have to modify the third party
code (if that's allowed, otherwise get them to patch it) to send the event
object when it calls your code.

[snip]

Mike
Please don't top-post.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Perttu Pulkkinen | last post: by
3 posts views Thread by niconedz | last post: by
10 posts views Thread by Paul Gorodyansky | last post: by
7 posts views Thread by Coder | last post: by
4 posts views Thread by tcole6 | last post: by
11 posts views Thread by Krij | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.