Search code examples
javascriptdom-eventsopera

How to add an onload eventListener to a popup in Opera


I'm writing an application that needs to call a function when a popup has loaded. Currently, this is what I'm using, which works in Firefox/Chrome/Safari:

var win = window.open(...);
win.addEventListener( 'load', function () {...}, true );

However, opera does not like win.addEventListener. I tried win.opera.addEventListener too, but that also didn't help.


Solution

  • For the record the solution which had been found previously

    var openedWindow = window.open("test.html", "title");
    
    window.setTimeout(function() {
        openedWindow.addEventListener("load", function() {
            console.log("received load event");
        }, false);
    }, 0);