Welcome visitor
* Login
* Register
It is currently September 19th, 2019, 4:40 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  Open popup but just once
PostPosted: December 18th, 2009, 9:35 am 

Posts: 15
Do you know if there's a way to open a popup window but just the first time the homepage is visited?


Top
 Profile  
 
  Re: Open popup but just once
PostPosted: December 19th, 2009, 12:01 pm 

Posts: 117
I found this on the web, it uses cookies, hope it helps...
<script type="text/javascript">
function set(cookieN,n,expiration)
{
xd=new Date();
xd.setDate(xd.getDate()+expiration);
document.cookie=cookieN+ "=" +escape(n)+
((expiration==null) ? "" : ";expires="+xd.toGMTString());
}
function handleCookie(cookieN)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(cookieN + "=");
  if (c_start!=-1)
    {
    c_start=c_start + cookieN.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function validateCookie()
{
visitsN=handleCookie('times');
if (visitsN > 0)
  {
  visitsN=Number(visitsN)+1;
  alert('Number of visits '+visitsN+'!');
  set('times',visitsN,5);
  }
else
  {
  firstTime();
  }
}
function firstTime()
{
nw=window.open('window popup just first visit cookie.htm','_blank');
  if(window.nw)
  {
  visitsN=1;
  set('times',visitsN,5);
  }
}
</script>
<body onload="validateCookie();">


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron