Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Making popup go to background

Posted on 2004-04-20
14
204 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
My first jQuery plugin: is the right tutorial missing? 2 100
Visitor to Web site (Log showing Strange IP Address) 9 118
Magento Indexing 1 102
.php tree directory? 5 83
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.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

791 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