Close opening window without using OK button

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?
 
C

Chris Jackson

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...?
 
K

Kathy Burke

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
 
M

mg

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?
 
M

mg

I need to use arguments like 'menubar=no' that window.open
() provide; so, simple navigation won't do.
 
C

Chris Jackson

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>
 
K

Kathy Burke

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
 
M

mg

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)
--




.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top