Making popup go to background

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
Who is Participating?
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,

you could set a cookie so that you know its been shown once.
then check for that value the next time.
look at this link to see how to set a cookie
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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

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;}?>

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

ZvonkoSystems architectCommented:
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.
ZvonkoSystems architectCommented:
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 :-)

GlenhomesAuthor Commented:
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!
We are all here for the help and to help.
The points are just a bonus
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.

ZvonkoSystems architectCommented:
Hello Glen,

thanks for points, but some feedback would be also nice :-)
GlenhomesAuthor Commented:
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,
ZvonkoSystems architectCommented:
Thanks for the feedback.
And yes, splitting points is always the best choice.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.