卸载刷新父页面上的IFrame [英] IFrame on unload refresh parent page

查看:114
本文介绍了卸载刷新父页面上的IFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面中有一个iframe。当iframe关闭时,我想刷新父页面。查看 iframe element w3 页面,我发现没有标准事件。

I have an iframe in a page. When the iframe is closed I would like to refresh the parent page. Checking out the iframe element w3 page I see there are no standard events.

我认为是一种轮询方法,让父页面不断检查是否创建了框架,然后检查它是否被删除然后刷新,但这种方法并不好。我可以想象,如果轮询不频繁,iframe关闭和页面重新加载之间有时会出现延迟。通过更频繁的轮询,页面会影响用户体验(急动)。

I considered a polling approach, having the parent page constantly check if the frame is created, and then checking if it is removed and then refreshing, however this approach isn't great. I can imagine sometimes delays between iframe close and page reload if the polling is to infrequent. With a more frequent polling the page would impact "user experience" (jerkiness).

我想知道是否有其他方法不涉及iframe父通信。

I'm wondering if there is another approach that does not involve iframe parent communications.

推荐答案

我不明白为什么你不会使用parent-iframe通信。由于所有内容都发生在iframe中的页面中,并且您只需要在发生这种情况后让父页面知道这一点,最好的方法是在父页面中调用一个函数,以便您可以部分刷新父页面而无需重新加载iframe本身。这样:

I don't see why you won't use parent-iframe communication. Since everything happens in the page within iframe, and you just need to let the parent page know about this after this happens, the best way is to call a function in parent page so that you can partially refresh the parent page without having to reload the iframe itself. This way:

window.parent.myFunctionInParent('my param');

您可以在如何从iframe中的页面部分刷新父页面

希望这会有所帮助。

这篇关于卸载刷新父页面上的IFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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