我有一个按钮,可以在两个iframe中加载两个不同的页面。我需要等待这些加载完成(例如ready(),不在乎图像和其他内容),然后触发其他操作。我怎样才能做到这一点?
一种方法是让iFrame内容发出已准备就绪的信号。这是一种简化的方法:
主页
var status = [false, false];
function doneLoading(index)
{
status[index] = true;
if (status[1] && status[2])
alert("Both iframes are done loading");
}
Run Code Online (Sandbox Code Playgroud)
在每个iFrame中
$(document).ready(function() { parent.doneLoading(1) }); // or 2
Run Code Online (Sandbox Code Playgroud)