Click to See Complete Forum and Search --> : Closing a popup from the parent window


cmptrnerd9
June 28th, 2007, 10:27 AM
I have window A....which opens up a popup (window B). Once I execute some vb.net code, I want window B to automatically close. Is there any code I can use to do that from window A? Javascript or VBScript would work.

Thanks,
Michael

PeejAvery
June 28th, 2007, 11:03 AM
From window A...
<script type="text/javascript">
// to open window
var popupWindow = window.open(url, name, parameters);

// to close window
popupWindow.close();
</script>

cmptrnerd9
June 28th, 2007, 12:31 PM
Thanks...but I plan to do it inline in vb.net code. Here is what I want

Respose.write("<script language='Javascript'>window.open('http://');</script>")

...more vb.net code

Response.write(..code to close the window above)

PeejAvery
June 28th, 2007, 12:50 PM
Thanks...but I plan to do it inline in vb.net code. Here is what I want
Then do it. Just put my code in Response.write() calls.

cmptrnerd9
June 28th, 2007, 01:03 PM
Sorry, I have been horrible in writing my question. The code that is used to open the popup is vbscript: window.showmodaldialog()....I tried what you said and that doesn't work with that vbscript. Do you have any other ideas?

PeejAvery
June 28th, 2007, 01:41 PM
You will have to change some things around, but here is a small VBScript example of opening and closing a different window.

<html>
<head>
<script type="text/vbscript">
Dim newWindow
Sub btnOpen_onClick
Set newWindow = Window.Open("http://www.google.com", "anotherWindow", "toolbar=no, menubar=no, width=640, height=480")
End Sub

Sub btnClose_onClick
newWindow.Close
End Sub
</script>
</head>
<body>

<input type="button" id="btnOpen" value="Open">
<input type="button" id="btnClose" value="Close">

</body>
</html>
Don't forget, client-side VBScript is IE only.

cmptrnerd9
July 5th, 2007, 09:00 AM
Thanks. I am trying to take your solution and adapt it to my situation. Below is the code written out when the page loads. However, when I go to write out the script to execute OpenWin and CloseWin, I get a "Type Mismatch 'CloseWin'" error. Can you advise?

Thanks,
Michael


<script language='VBScript'>
Dim newWindow
Sub OpenWin
newWindow = window.showModalDialog ("RCEProgress.aspx","wait","dialogHeight: 200px; dialogWidth: 300px; dialogTop: px; dialogLeft: px; edge: Raised; center: Yes; help: No; resizable: No; status: No;")
End Sub
Sub CloseWin
newWindow.close
End Sub
</script>

PeejAvery
July 5th, 2007, 10:31 AM
That is because, to my knowledge, you cannot close a modal dialog window using close. That is for open() which is why I used it in my example.

bigBA
July 6th, 2007, 03:13 AM
yeah, peejavery is right.

showModalDialog does not return until the _modal_ dialog is closed, confirmed, whatever from the user.
it shouldn't even return a window handle, instead it should return which button the user pressen (ok, cancel.... whatever).

a modal dialog has exactly the purpose, to interupt program execution until the user confirmed it.

greetings
bigba