0

I've got the following code in my parent window:

function OpenPopup()   {     
     var authWindow = window.open('t.php', 'authWindow', 'options...');
}

function HandlePopupResult(result) {
    alert("result of popup is: " + result);
}

And the following code in the pop-up:

 <script type="text/javascript">
function CloseMySelf(sender) {
    try {
        window.opener.HandlePopupResult(sender.getAttribute("result"));
    }
    catch (err) {}
    window.close();
    return false;
}    
 </script>

<a href="#" result="allow" onclick="CloseMySelf(this);">Allow</a>
<a href="#" result="disallow" onclick="CloseMySelf(this);">Don't Allow</a>

The first part of the function works fine, but the popup doesn't close. I read, that window.close only works if the popup has been opened by javascript, but I thought that was the case here?

window.close works fine, if I remove the opener-function. Is it because the script doesn't know that "window" refers to the child in the second instance?

4

1 に答える 1

0

親ウィンドウからポップアップを閉じることにしました

function HandlePopupResult(result) {
    authWindow.close();
    alert("result of popup is: " + result);
}
于 2013-01-26T14:20:15.320 に答える