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

Open new window and close old one 2

Status
Not open for further replies.

Shilohcity

Technical User
Jul 12, 2000
136
GB
Hi there

I have a popup window which direct people towards a registration page and I am wanting to force the popup window to close when people click on the register button. I know basic close window commands but cant seem to find a way to both open a new window and close the old one.

Does anybody have any suggestions they can offer me?


Thanks
Justin. X-) "Creativity is the ability to introduce order into the randomness of nature." Eric Hoffer

Visit me at
 
if(!oldwindow.closed)oldwindow.close()
newwindow=window.open("blah.htm","jive","whateverfeatures") jared@eae.net -
 
Hi there

Thanks for your help.

Now I am still a little confused about this. I guess I stick this at the top pf the page I want to close and then call it from the register link? but when I try this I get an error.

Thanks for your help. X-) "Creativity is the ability to introduce order into the randomness of nature." Eric Hoffer

Visit me at
 
are you confused on how to use jaredn's code? If so, try this..

Put jaredn's code into a function like this..

Code:
function closeAndOpen()
{
var newwindow

 if(!oldwindow.closed)
  oldwindow.close()
newwindow=window.open("blah.htm","jive","whateverfeatures")
}

the text oldwindow is to be replaced by the name you gave your original window with the register link in it. i.e.
If your original window is called regwin then use the code regwin.closed, and regwin.close())
the text "blah.htm" is to be replaced by the URL of the html file that will be the content of the new register window.
The text "jive" is to be replaced by the window title to be used i.e. "Please register" and the text "whateverfeatures" is the specially formatted string that tells the browser to open your new window with the specified features. The string to be used here is best explained by the resource you uesed to get the original code for your first popup window.
Hope that makes it clearer not cloudier!

Klae

You're only as good as your last answer!
 
Oh and finally you call the function when you click on the register link by using code like..
[COLOR=blue[
[code]

<A HREF=&quot;javascript:closeAndOpen()&quot;>Please register</A>

[/code]
[/color] Klae

You're only as good as your last answer!
 
Hi there

Thanks for all your help with this. I have finally got this working.

Thanks

Justin. X-) &quot;Creativity is the ability to introduce order into the randomness of nature.&quot; Eric Hoffer

Visit me at
 
hello. a question...
how do I close windows which i don't use?
can they close themselves when not using for a time period??
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top