kirupaji
kirupaji

Reputation: 1

php code on how to close the current window

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

Answers (3)

kirupaji
kirupaji

Reputation: 1

I have completed this task successfully, thank you all for your sharings.

Upvotes: 0

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146380

Get rid of all the PHP code you've shared. What you currently have is basically:

  1. JavaScript code to close current window:

     alert("Task closed successfully"); window.close();
    
  2. 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

Related Questions