garrisonian14 Posted November 30, 2007 Share Posted November 30, 2007 Hi, I am using php.When user clicks on a particular link a pop up window is opened (using javascript window.open method). In this window there is a form . on submiting this form we make entries in db. On success of entries i need to close this pop up and refresh the parent window. I close the pop up using javascript window.close function. but don't know how to refresh the parent window. Quote Link to comment Share on other sites More sharing options...
thebjorn Posted November 30, 2007 Share Posted November 30, 2007 In general, you refresh the original window by: opener.location = opener.location; most times when I've needed to do this I've ended up creating a hidden form in the opener and then have the child window copy values to it before submitting and closing itself, e.g. main window: <form method=post name=HiddenForm> <input type=hidden name=val1 /> </form> child window, script section: var submit_close = function() { // copy value(s) opener.document.HiddenForm.val1.value = document.VisibleForm.txtfield.value; opener.document.HiddenForm.submit(); // submit main window form window.close(); // close child window return false; } child window html: <form name=VisibleForm> <input type=text name=txtfield /> <button type=submit onclick="submit_close()">Submit</button> </form> It's a little more complex, but it solves the race condition where the reload of the main page finishes before the submit of the child window (and it looks like nothing happened). -- bjorn Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.