IFrame on unload refresh parent page
Asked Answered
D

1

1

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.

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).

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

Dunleavy answered 6/10, 2010 at 10:2 Comment(0)
D
1

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');

You can learn the technique step by step in How to refresh parent page partially from page within iframe.

Hope this helps.

Dissimilarity answered 19/7, 2011 at 12:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.