Closed Bug 272820 Opened 21 years ago Closed 21 years ago

JavaScript 'event' variable used in event handlers is defined as local variable

Categories

(Firefox :: General, defect)

x86
Linux
defect
Not set
minor

Tracking

()

VERIFIED DUPLICATE of bug 218415

People

(Reporter: wasik, Assigned: bugs)

References

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0 When using JavaScript as event handler like "onKeyUp" there is event variable which describes event type and keycodes, in Internet Explorer this variable is defined globally so every JavaScript function can access it even when it is not passed as parameter. In Firefox this variable is local so it can be used only in event handler which has to pass it as parameter to other functions. This makes IE optimized pages broken in firefox. It can be easily fixed in web page, but dissapointingly webmaster of my bank is not willing to make the change. Reproducible: Always Steps to Reproduce: 1.Include in you page code like this: <script language="JavaScript"> function EnableSend(pole) { if((event.keyCode!=9)&&(event.keyCode!=16)) { alert("event is ok"); } } </script> <input type="text" name="test" size="3" maxlength="3" onKeyUp="EnableSend(this);" ID="Text3"> 2. load page in firefox and try typing in textbox Actual Results: Actually nothing happened ie. MessageBox is not displayed, instead there is error in JavaScript console. Expected Results: In this case it should open MessageBox saying that event is ok.
This is probably a dupe. Can you provide the error message that appears in the JS console?
It's a dup of whatever unfindable original bz was talking about in bug 218415 - Mozilla and the W3C DOM don't have IE's global "the last event that fired, you better hope there aren't nested handlers firing multiple cascading events" object, so to work with both you say onkeyup="EnableSend(event,this);" and function EnableSend(event,pole).
*** This bug has been marked as a duplicate of 218415 ***
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → DUPLICATE
Status: RESOLVED → VERIFIED
*** Bug 290051 has been marked as a duplicate of this bug. ***
--> Websites :: www.mozilla.com so timeless can close out Firefox :: Product Site.
Component: Product Site → www.mozilla.com
Product: Firefox → Websites
-> Firefox::General (939393)
Component: www.mozilla.com → General
Product: Websites → Firefox
You need to log in before you can comment on or make changes to this bug.