Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Frame | Q1631 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.