View Full Version : Resolved How to reload and/or refresh an iframe...
Thanks in advance for your replies.
P.S.: I suppose some people might be also interested in how making such requests from the parent page, that is, a complete solution with all the four options.
08-08-2011, 04:39 PM
<a href="iframe.htm">Refresh From Cache</a>
From the parent page, you give the iframe a name attribute:
<iframe name="myframe" src="iframe.htm" . . . . . .></iframe>
and the link looks like so (same conditions as above):
<a href="iframe.htm" target="myframe">Refresh Iframe From Cache</a>
document.write('<a href="iframe.htm?bust=' + new Date().getTime() + '">Refresh From Server</a>');
Same thing for the parent page, just add the target:
document.write('<a href="iframe.htm?bust=' + new Date().getTime() + '" target="myframe">Refresh Iframe From Server</a>');
These are pretty simplistic examples. They work, but there's not much flexibility. You have to already know what page is in the iframe. From the page in the iframe, that's easy - it's that page. From the parent page, unless there are no other pages that could be in the iframe, that's harder.
But since you seemed primarily concerned with the page in the iframe, I won't go into the details of getting the page in the iframe from the parent to know which page to refresh. Also, with parent/child pages on different domains, no such communication is allowed.
I should add that using more sophisticated methods for something like this would require extensive cross browser testing, as the iframe is still non-standard in its implementation across browsers.
Once more, thank you so much, John!
A truly encyclopedic answer to my questions. It remains for future reference for anyone working with iframes and that is in trouble. "Moltes grącies".
By the way, if I'm not in mistake for a correct behaviour in your first example the target of the link must be set to self: target="_self". This is my two cents ... ;-)
Right now I have an issue with an object embedded in a page with jquery tabs with iframes: the second tab is "hidden" at first and when the web document is loaded, IE do not draw this object on the iframe file. I have to update manually the frame to works. I'm looking for a solution that refresh o call to this iframe when one select or click this second tab. A simple way to solve a complex problem.
08-09-2011, 01:57 AM
Unless a base target has been set for the page, the default target for any link is _self.
Was there another question in there? Or has this solved it for you?
All is OK.
I have to do my homework, if I can not get off the hook, I will ask for HELP!!!
Thank you, John.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.