Is it possible to close a modal window from it's parent? It is a little hard even to try to do this. Basically, I am opening a non-modal window. From that non-modal window the user might some times open a modal window. Now suppose I close the non-modal window... I would like the modal subwindow to close also. How can this be done?
Basically, overall, I have to find a way to close a modal window from it's parent.
Thanks, Grae
Here is some code to give you a sample.
The Start Page
<html>
<head>
<script>
window.childWindow;
function openNonModal()
{
window.childWindow = window.open("nonmodal.html","_blank", "dialogWidth=500px;dialogHeight=294px;scroll=no;status=no;caption=no;titlebar=no;menubar=no;toolbar=no;help=no");
setTimeout("closeChildWindow()",5000);
}
function closeChildWindow()
{
window.childWindow.closeChildWindow();
window.childWindow.close();
}
<script>
</head>
<input type="button" value="openNonModal" onclick="openNonModal(); return false;"/>
</html>
The nonModal window which open a modal window.
<html>
<head>
<script>
function openModal()
{
var retVal = window.showModalDialog("modal.html","_blank", "dialogWidth=500px;dialogHeight=294px;scroll=no;status=no;caption=no;titlebar=no;menubar=no;toolbar=no;help=no");
}
function closeChildWindow()
{
alert("should close child window");
}
</script>
</head>
<input type="button" value="openModal" onclick="openModal(); return false;"/>
</html>
The window that is modal is just text.
<html>
Just a sample.
</html>
Now suppose I close the non-modal window... I would like the modal subwindow to close also. How can this be done?
shouldn't that be the default behaviour? What happens at the moment - does the modal window in fact stay orphaned? – Pekka