モーダルポップアップから親クラスへの簡単な呼び出しを試みていますが、IE はずっと私と戦っています。それを回避するための提案は大歓迎です。
以下は、私が使用しようとしているコードを削除したものです。FireFox では問題なく動作しますが、IE ではエラーがスローされます。「オブジェクトはこのプロパティまたはメソッドをサポートしていません」というエラーが表示され、「Catch」ブロックのコード行が参照されます。これは、Try ブロックと Catch ブロックの両方の行が機能しないことを意味します。
親.html
<html><head>
<script>
function callMain(msg)
{
alert(msg);
}
function modalWin() {
if (window.showModalDialog) {
window.showModalDialog("topFrame1.html","name",
"dialogWidth:255px;dialogHeight:250px");
} else {
window.open('topFrame1.html','name',
'toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
}
}
function getMainFrameVal()
{
return document.getElementById("mainframe").value;
}
</script>
</head> <body>
<a href="#" onclick="modalWin()" >PopUpWindow</a>
<form>
<input type=text id="mainframe" value="main"/>
</body></html>
topFrame1.html
<html><head>
<script type="text/javascript">
function getMain(){
try{
alert("1 "+ window.opener.getMainFrameVal());
}catch(e)
{
alert("2 " +window.parent.getMainFrameVal());
}
}
</script>
</head> <body>
TOP <a href="#" onclick="getMain()">click for main</a> <br/><br/>
</body></html>