Closed Bug 205119 Opened 21 years ago Closed 21 years ago

document.addEventListener('load', ...) doesn't

Categories

(Core :: DOM: Events, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 99820

People

(Reporter: ian, Assigned: saari)

References

()

Details

The following script fails to execute:

    document.addEventListener('load', function() {
      document.getElementsByTagName('P')[0].firstChild.data = "PASS";
    }, true);

If I replace "document" with "window" it works fine. It also works if I use an
onload attribute or the window.onload property.

Testcase in URL.
Actually, the DOM spec does not define very well what this event should be fired
on.... DOM3 Events says something about firing it on an Element, which does not
make any sense at all for whole document loads.

What makes you think this event should ever fire with the document as the target?
Wouldn't it bubble all the way back to the document anyway? (I have no idea.)
Load devents do not bubble.  See the DOM Events spec.
Indeed. Ok. So, the spec doesn't say what we should fire it on, but it does say
that "unload" fires on <body>. Unfortunately, if you are adding the script from
some code in the <head> element of the document, there is no <body> to speak of.
So what's the standard compliant way to do this? Should I bring this up in
www-dom and ask the WG?
Probably a good idea, yes.
This is actually a dupe, I suck. I'll mail www-dom.

*** This bug has been marked as a duplicate of 99820 ***
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.