Alan H.
Alan H.

Reputation: 16608

What is wrong with this page onload code?

Please see this jsFiddle. Note that the click event works just fine (try clicking anywhere in the output), but not the document load event.

Upvotes: 0

Views: 69

Answers (2)

user113716
user113716

Reputation: 322622

The document requires DOMContentLoaded.

_bl_event(document, 'DOMContentLoaded', d1, false);
_bl_event(document, 'DOMContentLoaded', d2, false);

...though it isn't supported in all browsers.

Example: http://jsfiddle.net/bCtQQ/15/

This has different meaning from placing a load handler on window.

Upvotes: 2

Alan H.
Alan H.

Reputation: 16608

Ach, I finally got it — attaching the event to window instead of document seems to work much better.

Upvotes: 1

Related Questions