How To Reload An IFrame Document From Inside An IFrame?
IFrames, although out dated in web design, still play a very important role in today's websites. All the advertisements which are served today by leading Ad networks use the IFrame technology to deliver advertisements and without ads, the internet economy will come to a standstill.
Coming to the point of this article, we will now tell you how to reload an IFrame document from inside the Same or another IFrame document on the page. You can also use this method to reload any IFrame window that is present on a page.
Step 1: Give a name to the IFrame document. Simply add a name tag and an id tag. Both should have the same identifiers, for eg:
<iframe name="testframe" id="testframe" src="testframe.php" />
Step 2: The iframe statement is located inside another page say frames.php. Now inside the IFRame page, (testframe.php) we can put the following code, which will just refresh the IFRame document corresponding to that name / identifier and not the entire page:
function reloadIframe() {
target=window.parent.frames["testframe"]; /*Get the name of the iframe to reload*/
target.location=target.location; /*reload the iframe*/
}