マルチフレームアプリケーションがあり、各フォームは別々のフレームで開き、親ウィンドウからJSAPIを使用できます。APIは例外(エラー)をスローできますが、iframeでキャッチできません。IE8でのみ再現されます。IE8/IE9とChromeでチェックしました。例:
test.html
<html>
<head>
<script language="JavaScript" type="text/javascript">
var g_fn = {};
function onLoad() {
g_fn.thrown_error = function() {
throw new Error("Main window: error");
return 1;
}
window.g_fn = g_fn;
}
function window_do() {
try {
g_fn.thrown_error();
} catch (err) {
alert("Error catched!");
}
}
</script>
</head>
<body onload="onLoad();">
<input type="button" value="do smth in window" onclick="window_do();"/>
<iframe src="/iframe.html" />
</body>
</html>
iframe.html
<html>
<head>
<script language="JavaScript" type="text/javascript">
var g_fn;
function onLoad() {
g_fn = window.parent.g_fn;
}
function iframe_do() {
try {
g_fn.thrown_error();
} catch (err) {
alert("Error catched!");
}
}
</script>
</head>
<body onload="onLoad();">
<input type="button" value="do smth in iframe" onclick="iframe_do();"/>
</body>
</html>
それはIEバグですか?回避策はありますか?