How can I catch an exception thrown inside my iframe?
Here is my code:
Parent:
iframe = document.createElement("iframe");
iframe.src = "../a.aspx";
iframe.style.display = "none";
document.body.appendChild(iframe);
and the code inside a.aspx:
protected void Page_Load(object sender, EventArgs e)
{
GenerateKey();
//This function throws an exception, and I want to catch it in the parent window (javascript)
}
I want to catch the exception in the page that opens the iframe and show an alert box. I tried iframe.contentWindow.onerror, but it didn't work.
Thanks for the help,
Inbal.
Cross origin may disallow you to control iframe. Inside your iframe page, you can catch its exception and call parent function to display it.