Reputation: 10288
I have a big flaw in my idea and was wondering if anyone could help me. I have a script which I have written that runs on a page nicely. on that page there is an iframe, from which it's content is from a temporary web page ( temporary / dynamically generated for preview purposes ) which is in full working order ( i.e. it runs all it's Javascript / server side code as it would normally ). I have no control on what content is being loaded via the iframe so my problem is this. if there is an error within the Javascript code from the iframe ( this mainly applies to Internet Explorer ) then it stops the code from the parent running. Meaning I'm relying on people to be using correctly coded Javascripts for them to be able to use my service.
Is there anyway to stop the iframe stopping the parents code working?
Upvotes: 0
Views: 375
Reputation: 17472
You have to programmatically set the content in the iframe using javascript and do it in a try/catch block. So that any errors in the iframe will be caught and your script has effect on it.
See this post for more details
Upvotes: 1
Reputation: 5291
try {
document.getElementById('iframe').src = 'iframe.html';
} catch (e) {
//!!!
}
Upvotes: 1