Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery.error() is not working for iframe.

Tags:

jquery

iframe

I'm trying to use jquery to detect whether an iframe fails to load or the page doesn't exist, but the code below isn't working:

$('#frame').error(function(){
    //code here
});
like image 288
Kevin Pei Avatar asked Jun 22 '26 06:06

Kevin Pei


1 Answers

One of the comments on the documentation says:

Using .error() on an iframe never seems to trigger (even though .load() will trigger on a successful iframe load).

This event does not appear to be designed to work in this use case.

The answers to this question explain how to do it.

like image 101
Lightness Races in Orbit Avatar answered Jun 24 '26 11:06

Lightness Races in Orbit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!