views:

125

answers:

1

I'm loading an iframe by changing its src attribute and then registering a handler for its load event, i.e.

obj.iframe.attr('src', src); obj.iframe.load(function() { ... });

This works well as long as the iframe loads correctly. I'm wondering if there's an easy way using jquery to set a timeout for the iframe to load and detect errors if it doesn't load correctly.

A: 

You could put in the load function of the iframe a function which set a variable to true, and then use setInterval to check regularly if all is going ok. When the iframe is loaded correctly, you can use clearInterval to stop the checking operation.

Valentin Rocher