You can add an onerror attribute to your iframe, e.g.:
<iframe src="..." onerror="..."></iframe>
Here's a live example that uses two different methods using jQuery (which is included with in5 output):
I did some more testing and found the onerror event is only firing properly in Firefox.
These solutions offer a cross-browser method: https://jsfiddle.net/justinputney/jpaaytc4/2/
Essentially, it adds a navigator.onLine check inside the onload attribute of the iframe. If offline, the onerror attribute code is evaluated.