I am trying to make a simple call to the parent class from a modal popup, but IE fights me all the time. Any suggestions to get around it would be greatly appreciated.
Below is the remote code that I am trying to use. It works fine in FireFox, but causes an error in IE - "Object does not support this property or method", referring to a line of code in the "Catch" block. This means that both lines in the Try and Catch blocks do not work.
parent.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>
source share