PDA

View Full Version : detect error in iframe


babadi
06-26-2005, 03:53 PM
Hi folks,

Suppose I have an iframe defined as:

<iframe name='test' id='test' src='http://www.google.com/'></iframe>

Is there any way for the document to detect whether the contents of the iframe has successfully loaded or if an error has occurred?

Thanks,
Martin

nikkiH
06-26-2005, 04:11 PM
If the content is external, you can't directly check due to javascript security limitations. But you can check before you try to load it, either server-side or client-side.
Since you posted in the JS forum, here's the JS solution for checking for 404. Modify as desired to check for other errors.
http://www.ipwebdesign.net/useful_detect404.html