Tech Musings

Sunday, November 27, 2005

Javascript close pop-up window and refresh parent window

I use this code all the time for modify and update pages written in PHP. If I use a pop-up window, I find it is often desirable for the pop-up window to automatically close on update and for the parent page to auto refresh so users can see their updated data. This can be achieved by code similar to this being executed upon successful update.

die( "<-script->window.opener.location.reload();window.close();

modify_index.php in edtech's admin_data area and change_password.php in Pt. Loma's eportfolio projects are examples of where I used this technique.

>>>>>added 1-26-2006 >>>
Here is the JAVASCRIPT used to create the pop-up window that will close using the PHP/Javascript code above. I used this "resizable", "scrollable" pop-up window when creating the Helix GED628 syllabus page:

v a r openWin;

function winOpen(href, target, width, height, resize, scrollbars) {
if (openWin && !openWin.closed) {
openWin =, target, 'width=' + width + ',height=' +
height + ',resizable=' + resize + ',scrollbars=' + scrollbars);

a href="change_password.php?uid=" target="changepassword" onClick="winOpen(this.href,, 400, 140, 'yes', 'yes'); return false;"change /a


Post a Comment

Links to this post:

Create a Link

<< Home