Opera: Can't get load event from window.open()

不问归期 提交于 2019-12-02 06:09:08

问题


var openedWindow = window.open("test.html", "title");

openedWindow.addEventListener("load", function() {
    console.log("received load event");
}, false);

I want to get the load event from an opened window. The code above works, but the callback function does not get called in Opera 11.62 (works on other browser).

EDIT: It works when i register the event after 0ms timeout:

var openedWindow = window.open("test.html", "title");

window.setTimeout(function() {
    openedWindow.addEventListener("load", function() {
        console.log("received load event");
    }, false);
}, 0);

回答1:


this seems to be a known bug in Opera - I've pushed the internal bug report (CORE-46278) a little bit forward.

The only workaround I can think of is adding callbacks from the popup contents - type opener.popupLoaded(). This may however offer a performance advantage too - you can start interacting with the popup when its script environment is ready and the script you want to talk to is running, rather than waiting for the load event.



来源:https://stackoverflow.com/questions/10499709/opera-cant-get-load-event-from-window-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!