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!

One time Pop-up Window?

Status
Not open for further replies.

oleNorm

Programmer
Mar 23, 2001
1
US
Greetings - I use a pop-up window on the opening page of my personal web-site. The window works great - no problem, however I would like to know how to limit the pop-up window from opening if the user goes to a subsequent page on my site, then uses the backup key to return to the opening page. Using javascript (or other technique) how do I go about doing this?

Appreciate any help - olenorm
 
There are a number of ways. The easiest is to have a flag via a hidden input value. Right before the pop-up window opens, have the opener window set flag='1'. Also make sure to put the Pop-up in a conditional statement. example:

if (document.forms[0].flag.value != '1'){
document.forms[0].flag.value = 1;
window.open(blah, blah, etc);
}


The other way is to put the flag value in a session variable. example:
Session("Flag") = '1'

Then substitute Session("Flag") for document.forms[0].flag.value in the above code. This way, even if the user closes the opener window, you won't have it pop up again.


Or you could put it in a cookie.


I could go on, but I think you get the picture.

Best Regards,
DF
 
I use a tiny cookie with no retention date set so that it's only retained for the life of the browser session:

if (attempt to load the cookie fails)
do your popup
write the cookie
end if

For example the 'sorry' wording on:
You're welcome to use the global.js code I've put together (for this and other things...) idea as long as you credit me on any site which uses code based on it(and where I got some of the basic cookie code.)

you can get the source from:


Or drop me a note from the contact page of that site and I'll send it to you if you like...

Please let me know how you get on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top