I'm trying to change text on a page from an iframe on the page. When the user finishes uploading an image I want to change text saying loading... to finished uploading or something. Can this be done from an iFrame? I know when you use alert("Finished");
it alerts the user from the iframe, but I still have the loading text.
Asked
Active
Viewed 2,902 times
2

John Doe
- 3,559
- 15
- 62
- 111
-
possible duplicate: http://stackoverflow.com/questions/935127/how-to-access-parent-iframe-from-javascript – surfen May 21 '11 at 00:10
-
2Just want to point out that if the page in the iframe is on a different server you can have issues. Browsers have some built-in protection from cross-scripting, so sending data between a parent window and and iframe can be challenging. Plus FF and IE work differently, so I would definitely test in latest FF and IE 7 through 9. – AR. May 21 '11 at 00:17
3 Answers
1
Try using window.parent from within the iframe. This will point to the parent window.
You could execute a function (named, say, hideLoadingText) within the context of the parent window by doing window.parent.hideLoadingText();

Toby
- 647
- 4
- 14
1
on parent.html page (where there is an iframe)
function finished()
{
//you can change this below line depend on your needs
document.getElementById("status").innerHTML="Finish";
}
<span id="status"></span>
<iframe src="child.html" name="iframe_content"></iframe>
then you can try this on child.html page (content inside the iframe)
<input type="button" value="Finish" onclick="parent.finished()" />
also you can change the triger of the function depend on your needs

bungdito
- 3,556
- 4
- 31
- 38
0
window.parent.yourjavascriptmethodname();

Neelam
- 3
- 1
-
1Don't just put one-line code snippets, some explanation is appreciated on StackOverflow – Jan Doggen Aug 08 '13 at 13:41