简体   繁体   English

如何知道何时加载窗口弹出窗口?

[英]How can I know when a window popup is loaded?

Tried this my code: 尝试这种我的代码:

var w = window.open("http://www.jsfiddle.net");

if (w) {
    w.onload = function() {
        $('#complete').html("finished");
    };
}

but I'm far away from by target. 但我远离目标。 I want to write "finished" in the div when the window is loaded. 我想在窗口加载时在div中写“完成”。 How can I do it? 我该怎么做?

If you want to control from parent you could use ajax to grab the html and inject it into the popup window. 如果你想从父控制,你可以使用ajax来获取html并将其注入弹出窗口。

$.ajax({
   url:"somepage.html",
   success:function(html) {
     $('#complete').html("finished");
     var popup = window.open("");
     var doc = popup.document;
     doc.write(html);
   }
});

Though if the child page has scripts that depend on onload they may not fire, 虽然如果子页面具有依赖于onload的脚本,它们可能不会触发,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM