parent child windows- losing value of window.opener

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kewpe20
Forum Newbie
Posts: 7
Joined: Thu Sep 10, 2009 10:38 am

parent child windows- losing value of window.opener

Post by kewpe20 »

Hello all,

I've been trying to a resolve an issue with a parent page not reloading after a child form is submitted.
The initial problem is that I immediately lose the value of window.opener on the call to the child window.. What am I doing wrong?

Here is my call to the child window in my php file:

<a href="notes.php" class="actiontiny" target="_blank" onclick="modalWin('3','4','add' ); return false;">Add Note</a>

Here is the Javascript for modalWin function:
The alert statement results in "undefined" when it should result in the name of the parent's php file name....right?

function modalWin(type, id, func) {
alert(window.opener);
if (window.showModalDialog) {
window.showModalDialog("notes.php?type="+type+"&id="+id+"&func="+func+"","Notes", "dialogWidth:600px;dialogHeight:510px");
} else {
window.open('notes.php?type='+type+'&id='+id+'&func='+func+'','Notes',
'height=510,width=600,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
}
}
godwinsam
Forum Newbie
Posts: 9
Joined: Wed Sep 16, 2009 11:01 pm

Re: parent child windows- losing value of window.opener

Post by godwinsam »

Hello,

Please use the following code,
window.close();
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
Post Reply