Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with loading an iframe

Status
Not open for further replies.

DarVar

Programmer
Mar 14, 2006
10
IE
Hi I have the following html file with 3 Javascript functions:

I want to find a way to have function setFrame() call callPage(). Then have callPage() finish loading the iframe
then call finishedLoading(). And once finishedLoading() is complete function setFrame() will continue.

The problem is setFrame() continues on before finishedLoading() is complete.

<html>
<head>
<title>Test</title>
<script language="Javascript">
function setFrame(){
alert("here");
callPage();
alert("end");
}
function callPage(){
var myIframe = document.getElementById("iframe");

if (document.all) {
myIframe.onreadystatechange=function() {
if (myIframe.readyState=="complete" || myIframe.readyState=="loaded") {
finishedLoading();
}
};
}
else {
myIframe.onload=finishedLoading;
}
myIframe.src=" }
function finishedLoading() {

alert("myIframe loaded");
}
</script>
</head>
<body onload="setFrame();" id="body" bgcolor="red">
<iframe height="500" width="500" id="iframe" name="iframe" >
</iframe>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top