I have a site in which I take great pride in the fact that no javascript errors happen. New requirements make me have to put an iframe on my site which displays someone else's site of a different domain, and I have no access to their code. Their javascript consistently throws errors which causes users to see an ugly red x in the bottom of their browser.
Is it possible to handle that error on my end and disregard it?
Update:
In short, I'm trying to find a way to hijack the iframe's window.onerror handler.
Update:
I don't believe there is an answer here. Even if I could hijack the iframe onerror events, I don't think there's a way to make the ugly red 'X' go away. I'll leave the question here in hopes that I'm wrong.
I have a site in which I take great pride in the fact that no javascript errors happen. New requirements make me have to put an iframe on my site which displays someone else's site of a different domain, and I have no access to their code. Their javascript consistently throws errors which causes users to see an ugly red x in the bottom of their browser.
Is it possible to handle that error on my end and disregard it?
Update:
In short, I'm trying to find a way to hijack the iframe's window.onerror handler.
Update:
I don't believe there is an answer here. Even if I could hijack the iframe onerror events, I don't think there's a way to make the ugly red 'X' go away. I'll leave the question here in hopes that I'm wrong.
- Does the other site have some JSON way of getting data? – Detect Commented Oct 7, 2011 at 19:23
- @Detect I'm not sure what exactly you're asking, but I don't have any way to municate with the site or have any control over it. – tybro0103 Commented Oct 7, 2011 at 19:28
1 Answer
Reset to default 5What you're basically asking (I think) is "can I put a try/catch around the IFRAME's code", and the answer is no. However, you can e close, in many browsers at least (not Opera) by using window.onerror (and since the IFRAME has it's own window, you should be able to use this technique to capture only the IFRAME's errors).
See: Javascript global error handling for further info.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745610074a4635897.html
评论列表(0条)