4

모달 팝업에서 상위 클래스에 대한 간단한 호출을하려고하지만 IE가 계속 나를 싸우고 있습니다. 이 문제를 해결하기위한 제안은 크게 감사하겠습니다.IE7에서 window.parent를 호출 할 수 없습니까?

아래는 사용하려는 코드입니다. 그것은 FireFox에서 꽤 잘 작동하지만 "Object"는 "Catch"블록의 코드 라인을 참조하는 "Object는이 속성이나 메서드를 지원하지 않습니다"IE에서 오류를 발생시킵니다. 이것은 Try와 Catch 블록의 라인이 작동하지 않는다는 것을 의미합니다. 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> 
+0

설명을 원할 경우 답변을 수락하거나 의견을 말하면 답을 받아 들여야합니다. –

답변

0

window.opener

window.open()으로 팝업 열기와 함께 사용된다.

parent.html이 topFrame1.html의 부모이고 프레임 셋이나 무언가를 몰래 사용하고 있지 않습니까?

0

IE 모달 대화 상자는 실제로 진정한 창은 아니며 window.opener를 지원하지 않습니다.

alert("1 "+ window.dialogArguments[1].getMainFrameVal()); 
: 그럼 당신은이 라인을 가진 아이의 부모를 참조 할 수 있습니다

window.showModalDialog("topFrame1.html",["name", window], 
    "dialogWidth:255px;dialogHeight:250px"); 

: 부모 윈도우를 참조하려면이 같은 대화 상자 인수와 같은 일부 윈도우 참조를 전달해야 할 것입니다

제 조언은 IE 대화 상자를 멀리두고 모든 브라우저에서 작동하는 하나의 솔루션 (예 : window.open() 또는 jQuery dialogs)을 사용하는 것입니다.

관련 문제