Closed Bug 413262 Opened 18 years ago Closed 16 years ago

event failure

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bugzilla33, Unassigned)

Details

Attachments

(1 file)

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; FDM) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b2) Gecko/2007121120 Firefox/3.0b2 Events don't work whed added from JS. Reproducible: Always Steps to Reproduce: <body> <div><span id="el">element</span></div> <script> document.getElementById('el').onmouseover=function(){alert(event['type'])} </script> </body> Actual Results: error console: event id not defined Expected Results: Like this: <body> <div><span onmouseover="alert(event['type'])">element</span></div> </body>
Please attach a minimal testcase using the 'Add an attachment' link. thanks.
URL: null
Severity: major → normal
Version: unspecified → Trunk
To lunter@interia.pl(bug opener): See onmouseover attribute content of "el" by attached HTML. (1) Load HTML, and click "Check" button. (<span onMouseOver="alert(...);">) (2) Click "Change", and click "Check". (el.onmouseover=function()...};) onXXXX="script_code" in HTML tag is different from registration of event handler via JavaScript. As seen in test result, when onXXXX="script_code;", "function(event) { script_code; }" is registered by Firefox/Seamonkey. (This is the reason why event object is accessed via variable name of "event".) You *have to* use following statement, if you want to register event handler by yourself. > document.getElementById('el').onmouseover=function(e){alert(e['type']);}
Another way: document.getElementById("el").setAttribute("onMouseOver","alert(event['type']);");
The code in comment 0 assumes IE's window.event model of passing around events. If you had an |event| argument to your event handler, things would work fine.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: