Closed Bug 284834 Opened 19 years ago Closed 19 years ago

special object "event" doesn't seem to be recognized when passed through an event listener

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jag, Assigned: bugzilla)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1

when attaching an event listener that contains a function call making use of the
event object, the event object does not appear to be recognized. See example below:

myTestCase = document.getElementById('testCase');
myTestCase.addEventListener('click',function(){alertMyEvent(event)},false);

however, if I include the onClick event in the html object it appears to work
correctly, as seen here:

<span onclick="alertMyEvent(event)">test</span>

Reproducible: Always

Steps to Reproduce:
1. create a function that makes use of the event object
2. create an event listener for the 'click' event that triggers the
aformentioned function
3. open the javascript console and click the html object you attached the
listener to

Actual Results:  
The function failed and I received the following error in the javascript console:

Error: event is not defined

Expected Results:  
The function should have been passed the event that fired.
It's not a bug. Use:

myTestCase.addEventListener('click',function(event){alertMyEvent(event)},false);
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.