Solved

Making popup go to background

Posted on 2004-04-20
14
201 Views
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.
Glen
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
0
Comment
Question by:Glenhomes
  • 4
  • 3
  • 2
  • +4
14 Comments
 
LVL 6

Expert Comment

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

Assisted Solution

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

http://uk.php.net/manual/en/function.setcookie.php
0
 

Author Comment

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

Glen
0
 
LVL 10

Assisted Solution

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

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

<html><head>

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

</head>
</html>
0
 
LVL 1

Assisted Solution

by:klepa
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:
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

0
 
LVL 63

Expert Comment

by:Zvonko
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.
0
 

Accepted Solution

by:
TheEastern earned 400 total points
ID: 10869643
Glen,
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:
<SCRIPT LANGUAGE="JavaScript">

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) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
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) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
   }
}
</script>

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

<body OnLoad="checkCount()">
</body>


Let me know if you need anything explained any further,

TheEastern
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 63

Assisted Solution

by:Zvonko
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 :-)



0
 

Author Comment

by:Glenhomes
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

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

Expert Comment

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

Assisted Solution

by:Zyloch
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.

--Zyloch
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10886837
Hello Glen,

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

Author Comment

by:Glenhomes
ID: 10886902
Sorry,
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,
Glen
0
 
LVL 63

Expert Comment

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

Cheers,
Zvonko
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now