Search code examples
javascripthtmldom-eventsopera

Event listeners on plugin in document.onload events in Opera


I am trying to understand an issue where event-listener registration on plugins doesn't work in Opera unless I delay them.

In particular, this doesn't work:

document.onload = function() {
    plugin.addEventListener("foo", function() { alert('onFoo'); }, false);
}

while delaying the addEventListener() call somewhat through e.g. an alert() does:

document.onload = function() {
    alert('onload()');
    plugin.addEventListener("foo", function() { alert('onFoo'); }, false);
}

It seems that plugins are only loaded after document.onload.

As a non-web-developer, am I missing something simple here? Or is this a known Opera problem with a common work-around?


Solution

  • We have further improved handling of this in Opera 10.60, so that behavior is much closer to the other browsers wrt. plug-in initialization and script readyness. I believe the original approach should work now.