[英]Waiting for another page to load in JavaScript
is there a possibility to open a new window with JavaScript and wait with jQuery until the new page has finished loading? 是否有可能使用JavaScript打开新窗口并等待jQuery,直到新页面加载完成?
I tried the following, but it did not work: 我尝试了以下操作,但没有成功:
var win = window.open(url,'',windowSpec);
$(win.window).load(
function () {
alert('Finished loading');
}
);
Since the opened url is on the same server, it means that the two windows can communicate. 由于打开的URL在同一服务器上,因此这意味着两个窗口可以通信。
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
command use 并在启动window.open
命令的页面上使用
function yourmethod(){
alert('Finished loading');
}
Demo at http://jsfiddle.net/nmXdc/1 演示位于 http://jsfiddle.net/nmXdc/1
( the window that opens from the click is at http://jsfiddle.net/FPcMk/1/ ) ( 单击打开的窗口位于http://jsfiddle.net/FPcMk/1/ )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.