Reputation: 1
When I click a button it opens up a popup window, there I submit some values which will be processed under a server side code. My problem is, I need to close this window from there, I tried all the possible answers from the stackoverflow. any suggestions are appreciated
Here is the below code, which I used in the server side
echo '<script>alert("Task closed successfully"); window.close();
header("location: dispclosedtask.php?key=".$followuptaskid);
Upvotes: 0
Views: 1062
Reputation: 1
I have completed this task successfully, thank you all for your sharings.
Upvotes: 0
Reputation: 146380
Get rid of all the PHP code you've shared. What you currently have is basically:
JavaScript code to close current window:
alert("Task closed successfully"); window.close();
PHP code to load a different page before the browser has the chance of running prior JavaScript:
header("location: dispclosedtask.php?key=".$followuptaskid);
Everything you need is:
<script>
alert("Task closed successfully");
window.close();
</script>
Upvotes: 1
Reputation: 1764
after youre done submitting do this :
<?php
echo "<script>window.close();</script>";
?>
Upvotes: 0