Home > Informations, Javascript > Refresh parent window from child window with ShowModalDialog

Refresh parent window from child window with ShowModalDialog

Yesterday, I was in problem. Because, my supervisor told me to refresh main window from child window when child window is closed. I thought, I could do it with window.opener.location.href. Actually, it doesn’t work because this new window is created by showmodaldialog of javascript. That’s why I was running through on it. Finally, I got it.

Coding for parent window (main.html)

<input type=”button” value=”Open” onclick=”javascript:window.showModalDialog(“child.html”, window)”>

 

Coding for child window (child.html)

 

<SCRIPT LANGUAGE=”JavaScript”>
<!–
function close(){

if (window.dialogArguments && dialogArguments.location) {
dialogArguments.location.href = ‘main.html’;
window.close();

}}// –>
</SCRIPT>

<input type=”button” value=”Close” onclick=”close()”>

  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.