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?