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!

close method after redirect 2

Status
Not open for further replies.

bartee

MIS
Mar 20, 2005
147
US
Quick question:

I have a form -- on submit it opens a pop-up window.

The pop-up opens on submit.

After submitting, the main windows goes throught a series of re-directs and finally displays a page. At this point the pop-up is still visible.

I am trying to close the pop-up after the re-directs.

However, I am getting a javascript error saying that it cannot recognize the name.

Here is what I'm using to create pop-up:
Code:
 my_window = window.open("",
    "mywindow","status=1,width=350,height=150");

And to close it after re-direct:
Code:
my_window.close ();

Are you not able to close a named pop-up after a re-direct?

Thanks in advance.
 
Sorry,

correction on my closing code.

It actually says:

Code:
mywindow.close ();
 
Try to close the popup with

Code:
mywindow.close()

not my_window. my_window references the opening of the popup. You need only referece the name of the window to close it, which you named "mywindow".

[monkey][snake] <.
 
Right now, the pop-up is just basic html. No images or anything.

It doesn't seem to work blank either.

 
Try this: put
Code:
window.name = "mywindow"
in the HTML for the popup

also keep "mywindow" in your window.open statement.

This is a stab in the dark, but it's worth a try.
I'm thinking the main window "forgets" the name of the popup window on a redirect of the page. So setting the name of the window within the popup HTML should solve that.

[monkey][snake] <.
 
good suggestion.

However, I attempted it and it still does not recognize.
 
I'll test your situation out on my machine and see what I can come up with.

[monkey][snake] <.
 
You should close it BEFORE the opener page submission. I believe that the connection is to the original page, not any subsequent page redirected to or submitted to.

Lee
 
Yeah, I would like to but they want it to display until the final page has loaded (after the re-directs triggered by submit)

thanks
 
I found out what to do, and I have to give adam0010 the credit, so I will.


On your first page that opens the window, keep the syntax as you had it, naming the window there.

On the page AFTER everything redirects, put this in your javascript:

Code:
var thisWindow = window.open("", "mywindow");
thisWindow.close();

This "reestablishes" a connection with the popup window, without opening a new one, then you can close it.

**I did test this code.

[monkey][snake] <.
 
Yes, it works correctly now.

Thanks to everyone for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top