Let's discuss the current scenario:
- A webpage (
iframe.html
) contains an iframe that loads another page (iframe-content.html
). - There is a possibility of a JavaScript error occurring when
iframe-content.html
is loaded within the iframe. - The goal is to make sure that this exception is visible to the browser (for instance, displayed in the Firefox error console or Firebug).
This is what I have observed:
- When
iframe.html
is initially loaded and it loadsiframe-content.html
withsrc="iframe-content.html"
, the JavaScript exception displays in Firebug. - However, if the page is loaded using JavaScript (
), the exception is not shown.document.getElementById('iframe').src = 'iframe-content.html'
You can test this by visiting:
- on Firefox.
- Upon loading, you will see the exception as
iframe-content.html
is being loaded. - Click on the button: it will reload the content of the iframe, but this time the exception won't be visible in Firebug.
Is there a way at #3 to display the exception instead of it being ignored silently? (Note that wrapping the code that sets the src in a try/catch may not work as this code returns immediately before the page is fully loaded in the iframe.)