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

closing popups

Status
Not open for further replies.

cgillin

Programmer
Mar 20, 2003
58
US
I have a site where I would like to be able to open a new window when a user reaches my home page. If they reach some other pages on my site I would like to be able to close that window I had opened.

Not to sure if this can be done with just javascript or if I need to incorporate something like php to accomplish this. If anyone has any ideas let me know please.

Thanks for the help,
Chris
 
Here's an idea.
Write a cookie when you open the popup on the homepage (make sure your window has a name).
When another page from your website opens up check for the existence or value of the cookie. Based on that close the popup.



grtfercho çB^]\..
"Imagination is more important than Knowledge"A. Einstein
 
Yeah, I was trying to avoid cookies but that's probably the easiest way to go about it. Thanks for the advice.
 
in the pages that pop-up couldn't you just say

window.opener.close();

dlc
 
What I tried doing was creating a new window called newwin onload of my homepage. What I'm trying to do is close the window at another page by adding onload="newwin.close()". This won't close the window however. Any ideas how I could make this work.
 
If the second page is opened by the same window that opens newwin, you can probably get away with opener.newwin.close();

One way to cheat would be to remember the name of the window you're opening:

window.open("abcd.html","WINDOW_NAME");

Then, in the second page, you can:

Code:
var newwin = window.open("about:blank","[b]WINDOW_NAME[/b]");
newwin.close();

It's kind of cheap, I guess, but it works for me in IE6.

--Dave
 
Thanks Dave

Sometimes the cheap way is the best way. That worked out real well.

Chris
 
Chris,

Technically, thanks go to someone else on this board who had published this trick once before. I don't remember who it was, but I liked the trick, so I remembered it.

'glad it works!

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top