Close opening window without using OK button

  • Thread starter Thread starter mg
  • Start date Start date
M

mg

I need to first open WebForm2 from WebForm1 and then
close WebForm1 without the end user having to press an OK
button before the close can occur.

For example, possibly

Response.Write("<script language='javascript'>window.open
('WebForm2.aspx','two','menubar=no');</script>")

Is there code that will accomplish this without using 3rd-
party software?
 
You can window.close any window that you spawn yourself without a warning,
but you can't close the main window (that the user launched) without the
user's consent. If your current strategy is to have web form 1 open a new
window and then close itself, why is this functionally different than the
result of a window.navigate? You still end up with a single browser window
open, and no dialog. I'm confused as to why you need to open a new window at
all...?
 
Still javascript. For example, as the onclick event of a button that
opens webform(2) and closes the opener webform(1):

Response.Write("<script
language=javascript>window.opener.location='webform2.aspx';self.close();
</script>")

HTH,

Kathy
 
This doesn't seem to work. Are you sure about this code as
a way for one page to open another and then close itself
without the end user having to press the OK button?
 
I need to use arguments like 'menubar=no' that window.open
() provide; so, simple navigation won't do.
 
OK. Try this:

<html>
<script type="text/JavaScript">
function closeMe() {
window.opener = self;
window.close();
}
</script>
<body>
<input type="button" onclick="closeMe()" value="Close" />
</body>
</html>
 
Chris is right of course. I use this for when I've opened a pop-up
window, then when the user completes the form and opens another, the
close.self closes the pop-up.

Sorry if I confused things.

Kathy
 
By George, that did it!

Thank you.

-----Original Message-----
OK. Try this:

<html>
<script type="text/JavaScript">
function closeMe() {
window.opener = self;
window.close();
}
</script>
<body>
<input type="button" onclick="closeMe()" value="Close" />
</body>
</html>

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--




.
 
Back
Top