[patch] support document.body.onload

Leo Savernik l.savernik at aon.at
Wed Jan 5 20:44:45 GMT 2005


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.

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).

Can some kjs/ecma guru review the patch for any potential security issues, 
please?

To get an idea about the effect, look at the following snippets, and how 
various browsers handle it:

window.onload = f1;
document.body.onload = f2;

where f1 and f2 are arbitrary event handlers.


Mozilla 1.5:

calls f1
does not support document.body.onload


Internet Explorer 6:

does not call f1
calls f2


Opera 7.50:

calls f1
calls f2 (in this very order)


Konqueror 3.3.2:

calls f1
does not support document.body.onload


Konqueror 3.3.2 patched:

does not call f1
calls f2


Further investigation about IE's behaviour showed that document.body.onload is 
acutally synonymous to window.onload.

I. e.:

window.onload = f1;
document.body.onload = f2;

leads to

window.onload == document.body.onload


Konqueror's behaviour matches IE's (because it was the easiest to implement).

I propose that the patch is added to KDE_3_3_BRANCH and HEAD.

mfg
 Leo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: khtml_js-body-onload_1.diff
Type: text/x-diff
Size: 4134 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20050105/bd27dafa/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20050105/bd27dafa/attachment.sig>


More information about the kfm-devel mailing list