Making popup go to background

Posted on 2004-04-20
Medium Priority
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: www.glencare.com
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 80 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.

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 10

Assisted Solution

rockmansattic earned 80 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 80 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:
var win_one=window.open('url1','windowname','properties');win_one.blur();window.focus();
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 1600 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 glencare.com domain was redirecting to a glenhomesgroup.co.uk domain.
Try to update the original one (glenhomesgroup.co.uk), 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);

window.open(page, "", 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 80 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 80 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

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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.

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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…

569 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