Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1631 How can I chec that a frame that holds a function that I want to invoke has loaded the function successfully?

You are here: irt.org | FAQ | JavaScript | Frame | Q1631 [ previous next ]

If you have two or more frames in a frameset, then the order and speed in which they load is unpredicatable, therefore if you invoke a function in one frame from another it is possible that the function will not have been defined by the time you invoke it. In which case you need to test to see if it is defined before you attempt to use it. If it isn't defined then you can use setTimeout to perform the test again after a delay:

<script language="JavaScript"><!--
function localFunction() {
  if (parent.otherFrameName.remoteFunction) {
    parent.otherFrameName.remoteFunction();
  }
  else {
    setTimeout('localfunction()',500);
  }
}
//--></script>

©2018 Martin Webb