is there a possibility to open a new window with JavaScript and wait with jQuery until the new page has finished loading?
I tried the following, but it did not work:
var win = window.open(url,'',windowSpec);
$(win.window).load(
function () {
alert('Finished loading');
}
);
is there a possibility to open a new window with JavaScript and wait with jQuery until the new page has finished loading?
I tried the following, but it did not work:
var win = window.open(url,'',windowSpec);
$(win.window).load(
function () {
alert('Finished loading');
}
);
Share
Improve this question
edited Dec 19, 2014 at 17:25
APerson
8,4308 gold badges38 silver badges49 bronze badges
asked Sep 20, 2012 at 11:53
JanusJanus
3091 gold badge5 silver badges18 bronze badges
4
- 3 is the url in the new window on the same domain as the calling script? – Gabriele Petrioli Commented Sep 20, 2012 at 11:57
- Yes, it's all on the same server. – Janus Commented Sep 20, 2012 at 12:05
- Can you edit the page loading in the popup? so to insert some javascript in it? – Nelson Benítez León Commented Sep 20, 2012 at 12:09
-
I tried it in the meantime and tried to access the second window with the following
$(win.window).load
and for the finishing of the loading. But it does not work. – Janus Commented Sep 20, 2012 at 12:12
1 Answer
Reset to default 5Since the opened url is on the same server, it means that the two windows can municate.
Add on the page that opens in the window
$(window).load(function() {
var opener = window.opener || window.dialogArguments;
if (opener) {
opener.yourmethod();
}
});
and on the page that initiates the window.open
mand use
function yourmethod(){
alert('Finished loading');
}
Demo at http://jsfiddle/nmXdc/1
(the window that opens from the click is at http://jsfiddle/FPcMk/1/)