Php And Window.close In Javascript
I have a problem. I have a page that when you click a button, a popup with a form is shown. So, I complete some data and I submit. What I want to do is, to submit the form, close t
Solution 1:
I use this to reload the page that opened a popup window:
<scriptlanguage="JavaScript"><!--
function reloadParentPage() {
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow) {
window.opener.progressWindow.close()
}
window.close();
}
//--></script>
By the way, the code above is called by a link or button in the popup page.
Solution 2:
You have a race condition between the script doing the insert and the script reloading the parent.
The solution is to call refreshParent on the page after the submit - that way you know the data is in the database. You don't even have to do it on document ready - return a stub page that just defines and calls refreshParent in the head tag.
Solution 3:
In PHP when you run post script, at the end, include this code :
echo '<html><scriptlanguage="javascript">
parent.location.href="http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"].'"; // or any other url</script></html>';
This will output a javascript that will reload the windows.
Post a Comment for "Php And Window.close In Javascript"