Making popup go to background

Posted on 2004-04-20
Last Modified: 2010-04-06
Hi guys,
Im using Dreamweaver MX to design a website,and simple php scripts that all point to the homepage (ie <a href="<?php echo $_SERVER['PHP_SELF'].'?op=adolescentmental';?>">).
Im trying to create a popup when one visits the homepage, just to let them know we are moving premises.

The pop up is working fine, but when it is closed and another page is visited, it comes back up. This is because all the pages are generated from the home page.

Could anyone help me figure out a way, either to make it appear just once and not again, or to make it go to the backgrond when the close button is pressed.
Needless to say, this is VERY urgent.
Have a look at what I mean:
When the popup appears, close it and then click on one of the other links
Question by:Glenhomes
  • 4
  • 3
  • 2
  • +4

Expert Comment

ID: 10867617
you could set a cookie so that you know its been shown once.
then check for that value the next time.

Assisted Solution

jkna_gunn earned 20 total points
ID: 10867625
look at this link to see how to set a cookie

Author Comment

ID: 10867903
OK, this looks like what I need but I'm not gonna lie.
I need some more help here.

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

LVL 10

Assisted Solution

rockmansattic earned 20 total points
ID: 10868436
Possibly something like this, (just to add to jkna gunn)
$value = 'true';

if (!isset($_COOKIE['beenhere'])) {
   $javacode = 'complete javascript code: <script>  </script>';
   setcookie("beenhere", $value);
else {echo 'you have been here before'; }


<?php if (isset($javacode)){echo $javacode;}?>


Assisted Solution

klepa earned 20 total points
ID: 10869589
Just set the pop up proporties to appear in a back. And everytime you'll click on a link it won't show up.

so use this code:
and it should work, just initialize it onload and you'll be set

LVL 63

Expert Comment

ID: 10869595
I would not do it by a cookie, I would use and hidden field on that homepage.
The first popup does assign a flag value to that hidden field.
Popups check the hidden field value and suppress the popup accordingly.

Accepted Solution

TheEastern earned 400 total points
ID: 10869643
Just had a look through you source and updated a little something I had so it should work.
However, I noticed from your website that the domain was redirecting to a domain.
Try to update the original one (, although I'm not sure if the cookies will 'respect' the redirection of a website. I'm 100% sure it will work for the 'original' domain though.
I have included as many changes as possible (eg including the hqmove.php), just to make it a little simpler for you.

You will notice that there is alot more in the head section than you need, just incase you are interested in taking it any further.

Here it goes...
Put this in your head section:

var expDays = 0.0026041; // number of days the cookie should last (in this case just three and a half minutes)

var page = "pages/hqmovepopup.php";
var windowprops = "width=400,height=250,scrollbars=no left=600 top=400 screenX=300, screenY=400";

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;  
return null;
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
return 1
else {
var newcount = parseInt(count) + 1;
return count
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));

function checkCount() {
var count = GetCookie('count');
if (count == null) {
SetCookie('count', count, exp);, "", windowprops);

else {
SetCookie('count', count, exp);

Then, include the onload event handler in your body tag:

<body OnLoad="checkCount()">

Let me know if you need anything explained any further,

LVL 63

Assisted Solution

Zvonko earned 20 total points
ID: 10869661
You do not even need no form fields!
Because you want only to show the popup on the initial call of the homepage you could use also a global JavaScript variable.
If no query_string was passed to homepage invocation url, then is that global popup semaphore set to green, whit query_string was used in the url, then you set the popup semaphore variable to red :-)


Author Comment

ID: 10869795
Just got back in.
I'm gonna have a read through all and get back to this tomorrow.
Thanks for all the responses

PS: The Eastern-You REALLY want the points, don't you?? Great answer though, hope it works!

Expert Comment

ID: 10869814
We are all here for the help and to help.
The points are just a bonus
LVL 36

Assisted Solution

Zyloch earned 20 total points
ID: 10876861
Of course, TheEastern. I agree with Zvonko. You can use a form and use document.formname.submit() if you want or do the Javascript global variable. With the form however, you can send it by method=post and then check for it with PHP. If the setting is true, then suppress the popup, but if the setting is false, show the popup.

LVL 63

Expert Comment

ID: 10886837
Hello Glen,

thanks for points, but some feedback would be also nice :-)

Author Comment

ID: 10886902
I must have forgotten to click on submit before splitting the points coz I HAD typed something.
The solution from the Eastern is working exactly as he said it would, which is why I have accepted his/her answer. Also, s/he had taken the liberty to visit the website and take observation of the redirection & files.

I split the rest of the points between everyone else because you definately were pointing me in the right direction (starting jkna_gunn). And, of course for the quick responses!

Thanks again,
LVL 63

Expert Comment

ID: 10886990
Thanks for the feedback.
And yes, splitting points is always the best choice.


Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to i line up css containers from left to right 35 23
My first jQuery plugin: is the right tutorial missing? 2 92
How to translate path in URL with PHP? 11 46
Animated .jpg? 13 81
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question