JQuery - 等待加载两个iframe [英] JQuery - Wait for two iframes to load

查看:119
本文介绍了JQuery - 等待加载两个iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,可以在两个iframe中加载两个不同的页面。我需要等待那些负载完成(比如ready(),不关心图像和其他内容),然后触发另一个动作。我该怎么做?

I have a button that loads two different pages in two iframes. I need to wait for those loads to complete (like ready(), don't care about images and other content) and then trigger another action. How can I do this?

推荐答案

一种方法是让iFrame内容发出信号表明它已准备就绪。这是一种简单的方法:

One way would be for the iFrame content to signal that it is ready. Here is a simplistic way to do this:

主页

var status = [false, false];

function doneLoading(index)
{
   status[index] = true;
   if (status[1] && status[2])
      alert("Both iframes are done loading");
}

在每个iFrame中

$(document).ready(function() { parent.doneLoading(1) }); // or 2

这篇关于JQuery - 等待加载两个iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆