user717236
user717236

Reputation: 5039

FireFox4 doesn't recognize event object, anybody else having this issue?

I wonder if anybody else is having this issue. I'm using Firefox 4 and I'm debugging a function from an onclick event using Firebug. Now, to be sure, I checked the stack and it clearly shows that an onclick event was fired. However, when I type "event" (without quotse) in the watch pane, it says it's undefined. Why? Now it recognizes "Event", but not "event". Is anybody else having this issue?

Thank you.

Upvotes: 0

Views: 124

Answers (1)

DavidJCobb
DavidJCobb

Reputation: 1131

When debugging inside of your event function, add a watch for arguments[0]; this is the event object you are looking for.

Modern, standards-compliant browsers don't use a window.event object in the manner that some versions of Internet Explorer do.

In these browsers, the event is passed to the event handler as an argument. So if you do something like the following...

function foo(bar) {
   // do stuff
}
document.getElementById("myElement").onclick = foo;

...then when #myElement is clicked, the browser will execute foo(bar), where bar is the event object. If you need to see the event object's details, you would have to set a breakpoint inside of foo and add a watch for bar or for arguments[0].

Upvotes: 2

Related Questions