Is there any way to catch an error when loading an iframe from another domain. Here is an example in jsfiddle. http://jsfiddle.net/2Udzu/ . I need to show a message if I receive an error.
Here is what I would like to do, but it doesn’t work:
$('iframe')[0].onerror = function(e) {
alert('There was an error loading the iFrame');
}
Anyone have any ideas?
The
onerroris applicable only for script errors. Frame content error checking must be done using any other method. Here’s one example.Due to cross domain restriction, there’s no way to detect whether a page is successfully loaded or if the page can’t be loaded due to client errors (HTTP 4xx errors) and server errors (HTTP 5xx errors).