Detect failure to load contents of an iframe

If you have control over the iframe page (and the pages are on the same domain name), a strategy could be as follows:

  • In the parent document, initialize a variable var iFrameLoaded = false;
  • When the iframe document is loaded, set this variable in the parent to true calling from the iframe document a parent’s function (setIFrameLoaded(); for example).
  • check the iFrameLoaded flag using the timer object (set the timer to your preferred timeout limit) – if the flag is still false you can tell that the iframe was not regularly loaded.

I hope this helps.

Leave a Comment