Hi guys I'm using this function to open a popup and close it after 3 seconds. The popup opens successfully, but, the settimeout function doesn't works and eventually doesn't close the opened popup. What am I doing wrong here?
<script type="text/javascript">
function popUp(id,entry,escape)
{
popupWindow = window.open('process_concur.php?id='+id+'&entry='+entry+'&escape='+escape,'Concur','resizable=yes,scrollbars=yes,width=250,height=250');
popupWindow.focus();
setTimeout(function () { popupWindow.close();}, 3000);
}
//reload the current window when the popup is closed.
function popUpClosed() {
window.location.reload();
}
</script>
The popup page which opens (Code)
<?php
include 'classes/class.user.php';
$userMain = new user();
//get parameters
$id = isset($_GET['id']) ? $_GET['id'] : '';
$entry = isset($_GET['entry']) ? $_GET['entry'] : '';
$escape = isset($_GET['escape']) ? $_GET['escape'] : '';
//now, $escape is sha1 and $entry is base64 encoded..decode entry and check if sha1 of decoded entry matches escape
$dentry = base64_decode($entry);
if(sha1($dentry)==$escape)
{
//process concur
if($userMain->reviewExists($id))
{
if($userMain->increaseConcur($id))
{
echo "Done";
exit();
}
}
else
{
//review doesnt no exist
echo "Some problems occured at id doesn't exist";
}
}
else
{
echo "Some problems occured dentry";
}
?>
<script>
window.onunload = function() {
if (window.opener && !window.opener.closed) {
window.opener.popUpClosed();
}
};
</script>