Friday, January 18, 2013

Get result from popup window + Javascript

Well, rather than I write. Easy with the example.


a.html

<html>
<a href="#"  onclick="window.open('b.html', '','width=220,height=265');">Get Value</a>
<script type="text/javascript">
function HandlePopupResult(result) {
alert('Result of popup is: ' + result);
}
</script>
</html>


b.html

<html>

Make an action
<a href="#" result="Allow" onclick="return CloseMySelf(this);">Allow</a>
<a href="#" result="Disallow" onclick="return CloseMySelf(this);">Don't Allow</a>
<script type="text/javascript">
function CloseMySelf(sender) {
    try {
        window.opener.HandlePopupResult(sender.getAttribute("result"));
    }
    catch (err) {}
    window.close();
    return true;
}
</script>
</html>



Cheers!!!

No comments:

Post a Comment