Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reload the opener of showModalDialog 1

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
US
Hi,

Does anyone know how to reload the opener of a ModalDialog?

This opener.location.reload() won't work.

Thanks.
 
Open the modal dialog using "self" as the second parameter:
Code:
window.showModalDialog("myModalForm.htm", self, myOptions)
Then in the modal window (I'm guessing that you have a "Close" button) OnClick="CloseMe()".
Code:
<script language="vbscript">
sub CloseMe()
   window.dialogArguments.location.reload()
   Window.close()
end sub
</script>
 
Thanks Veep. Now I can reload the parent window. The ModalDialog is closed but then it open a different window(it's the same page but it's not modal, it's modaless or just regular window)

Thanks.
 
Here's a simple example that doesn't display the behavior you're describing. It displays the time on the parent page and then refreshes it when the modal dialog is closed.

Parent: OpenDialog.asp
Code:
<SCRIPT language="javascript">
function OpenDialog(){
    window.showModalDialog("modal.htm", self,"dialogheight:100px;dialogwidth:150px;");
}
</SCRIPT>

<FORM NAME=myForm>
<INPUT TYPE="button" VALUE="Click To open"onclick="OpenDialog()">
</FORM>

<%
response.write("<HR>" & Time())
%>
Modal Dialog: Modal.htm
Code:
<script language="vbscript">
sub CloseMe()
   window.dialogArguments.location.reload()
   Window.close()
end sub
</script>

<FORM NAME=myOtherForm>
<INPUT TYPE="button" VALUE="Click To Close" onclick="CloseMe()">
</FORM>
Try it out.
 
My modal.asp is a little different. It allows user edit some data, save to the db, and then close.

Anyways, I found a work around. Only after data is saved, I set the variable CloseWindow = True. Then in the body of the modal, I have this

Code:
<body <%If CloseWindow = True Then%>onLoad="window.close()" <%End If%>>

This does the trick for me. Thanks for your help.

-kendel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top