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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Redirect and Closing Window

Status
Not open for further replies.
Mar 14, 2002
711
US
Is there any way to close Window 1 after I am redirected to Window 2 using a Response.Redirect command? I have this command on page 1 which takes me to a confirmation screen in a new window:

Response.Redirect "thank_you.asp"

But when it opens up in a new window, it still leaves the original page open with all the selected form values still showing.

Thanks for any ideas on this!
 
response.redirect doesn't open a new window, it displays the new page in the current window. You must be doing something else to create a new window.
 
yup, how do u open a new window?

Known is handfull, Unknown is worldfull
 
I have no idea now :- / , I am looking at the code (inherited code from someone here at work) and I cannot find anything redirecting it to a new window in the script...I thought I remembered reading that you could not redirect a page to a new window,frame etc using response.redirect, but apparently something in my code is??

I will mull it over with a magnifying glass and see what is causing this...

Thanks guys,
 
let me get this right
when you click on a link you want a new window to open and the old one to close? Easy enough, though I don't know the exact code.

In the body tag of the orginal window call the window something. Here I'll call it windowA.

Open the new window using javascript, call the new window something
windowB here
In the Body tag of WindowB use javascript to close windowA.

Sorry I dont know the exact code but thats the logic on how to do it.

Scott Heath
AIM: orange7288
 
I used this to get it to work, but it is still not what I want since after I get to my Thank You page you have an option of going back to the main menu from which you can create another work order. The issue is now when you close the parent window, and you decide to go back to create a second work order and submit it, it will close the window before the thank you page loads a second time...

Take a look:

InputForm.submit()

window.opener = null
window.close()
return = false
 
My guess is that the original form opens a new window for the form handler (there is a target="_blank" in your original form tag).

In this case, what you really want to do is close the window that was opened while redirecting the original page...

formhandler.asp
<%
'confirm the login here
nextPage = &quot;thank_you.asp&quot;
%>
<script>
window.opener.location.href = &quot;<%=nextPage%>&quot;
self.close()
</script>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
What does not make sense with this page is that if I open Window 1, fill out the form data and submit to DB, page 2 opens in a new window. From page 2 I have an option that takes me back the main menu from where I can open page 1 again, but this time when I submit the data from page 1, it does not redirect to page 2 in a new window, but within itself like it is supposed to.

I did not find a target_blank in the forms handler page either...this is so bizarre.
 
I found another posting on the web stating that a response.redirect only redirects within itself, it is not smart enough to open a new window, etc, unless the page it redirects itself too has some javascript opening a new page or the browser is set to open a new window on a redirect - any comments on this? I looked at the second page and nothing in there showed a new window statement, and I even redirected it to a brand new blank page, same effect, opens in a new window. I will check Technet to see if the browser settings may be at fault.

Thanks,
 
CAn you post teh page that calls the popup and the popup apge somewhere in a text version and I will fix it for you
 
It is all on an Intranet and I do not have a public space where I can post the whole page, I could post the snippets of each page....
 
It is my first page that redirects it to a new window, because on page 2 I have another redirect command and it opens in the same window as itself, so there must be something I am missing on page 1 that calls it to a new window as it does not matter what page I redirect to.
 
OK, I will kick myself in the head right now as I found this rookie mistake....

</script>

<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;default.css&quot;>
<style>
div {
position : absolute;
/*border:blue 1px dashed;*/
{
span{
border:blue 1px dashed;
height : 20px;
}
#fs{font-size:11px;}

</style>
<base target=&quot;_parent&quot;>

</head>

base target was originally set to main which opened a new window as I was using the &quot;parent&quot; window, so I changed that to _parent and it is working like a charm. Thanks for all your help guys,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top