In IE there seem to be a global variable window.event, holding the current
event....howeve r this dowsn't work in FireFox... is there a similar way to
get the current event??
[color=blue]
> In IE there seem to be a global variable window.event, holding the current
> event....howeve r this dowsn't work in FireFox... is there a similar way to
> get the current event??[/color]
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.onevent name
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) ;
}
};
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...somethi ng like window.event
Regards,
Søren
"Martin Honnen" <mahotrash@yaho o.de> wrote in message
news:41b05695$0 $16039$9b4e6d93 @newsread4.arco r-online.net...[color=blue]
>
>
> Søren M. Olesen wrote:
>
>[color=green]
>> In IE there seem to be a global variable window.event, holding the
>> current event....howeve r this dowsn't work in FireFox... is there a
>> similar way to get the current event??[/color]
>
> 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.onevent name
> 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/[/color]
On Mon, 6 Dec 2004 07:07:35 +0100, Søren M. Olesen <smolesen@hotma il.com>
wrote:
[color=blue]
> [...] I really looking for some other way to get hold of the
> event...somethi ng like window.event[/color]
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.
Comment