[patch] support document.body.onload
David Faure
faure at kde.org
Fri Jan 7 00:02:39 GMT 2005
On Wednesday 05 January 2005 21:44, Leo Savernik wrote:
> Hello,
>
> My university's home page relies on a stupid dhtml menu that needs support for
> document.body.onload.
>
> Up to now, khtml ignored onload event handlers assigned directly to any other
> object than window.
Ah. <body onload="..."> works though... This is because HTMLBodyElementImpl::parseAttribute
sets the event listener onto the document.
> My patch overloads onload for KJS::HTMLElement of type DOM::HTMLBodyElement so
> that it forwards the event handler registration to the respective window
> event (it's essentially taking the same actions as
> HTMLBodyElement::parseAttribute).
I think you're not doing the same as HTMLBodyElement. That one sets the event listener onto
the *document*. You're setting it onto the *window*.
IMHO you should be doing doc->setHTMLEventListener like DOMNode::setListener does.
This would also fix the difference with <body onload="..."> + window.onload :
when doing it that way, both are emitted, as khtmltests/regression/tests/events/normal.onload.html says.
Hmm. Seems that KHTML changed its behavior since I wrote normal.onload.html...
document.onload=... didn't work at the time, but works now,
and document.body.addEventListener("load", ...) worked at the time, but doesn't work anymore
:(
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kfm-devel
mailing list