event listeners on plugin in document.onload events in opera

Posted by gf on Stack Overflow See other posts from Stack Overflow or by gf
Published on 2010-03-01T03:35:56Z Indexed on 2010/04/13 2:13 UTC
Read the original article Hit count: 503

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?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html