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

RESOLVED DUPLICATE of bug 99820

Status

()

RESOLVED DUPLICATE of bug 99820
16 years ago
16 years ago

People

(Reporter: ian, Assigned: saari)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
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?
(Reporter)

Comment 2

16 years ago
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.
(Reporter)

Comment 4

16 years ago
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.
(Reporter)

Comment 6

16 years ago
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
Last Resolved: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.