Reputation: 301
I have 3 php files: view.php
, edit.php
and edit2.php
.
I use view.php
to display content of my DB tables, edit.php
to edit a specific row (I use textboxes etc.) and edit2.php
to write any changes to my database. After the query is successfully executed, edit2.php
uses header("Location: edit.php");
to display the chosen row again (I use session variables in edit.php
and unset them on view.php
).
edit.php
and edit2.php
are opened in a small popup window. Now what I would like to have is when I close my small window, view.php
should be refreshed.
I tried using onunload
but what it does it is triggers itself each time a button is clicked in edit.php
to send data to edit2.php
, so when it returns to edit.php
, it's blank because session variables are unset due to refreshing of view.php
.
I have this strange feeling, that I might have explained it in a twisted way... Nevertheless, I would need some help.
Upvotes: 0
Views: 779
Reputation: 1492
What you want to do is open a new window using window.open('edit.php')
Here is the documentation for window.open()
Then watch for when the new window is closed, and refresh the page when that happens. Unfortunately there is no 'on close' event that's fired, but there is a property window.closed
that you can watch to see when the window is closed.
So this is what you should do:
var win = window.open('edit.php','Edit Row','width=800,height=600,status=0,toolbar=0');
var timer = setInterval(function() {
if(win.closed) {
clearInterval(timer);
location.reload()
}
}, 1000);
Upvotes: 1