markzzz
markzzz

Reputation: 47945

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. How can I do it?

Upvotes: 0

Views: 1870

Answers (1)

Patrick Evans
Patrick Evans

Reputation: 42736

If you want to control from parent you could use ajax to grab the html and inject it into the popup window.

$.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,

Upvotes: 2

Related Questions