Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Sat Nov 21, 2009 5:40 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ]  Bookmark and Share
Author Message
 Post subject: On page load, if cookie set then hide div?
PostPosted: Mon Jun 15, 2009 10:15 am 
Offline

Joined: Fri Jul 04, 2008 10:01 pm
Posts: 19
Hi there,

I'm not very good with Javascript so I need you help for page on my website...

Basically what I need to do is to make a DIV shown only first time someone visits page, and then when he/she revisit it I want that same DIV hidden, and I want it hidden for next 24 hours... so in that way DIV would be shown only once a day, and only on first page load.

So to make that happen I need to do fallowing, and I would need your help for that: I need a script that on a page load checks if cookie (which is 24h cookie) is set, if it is then it should hide that DIV, if it is not set then it should set it, so that DIV would be hidden on next page load...

Can someone help me with this, cause I am getting mad trying to do this whole day...

Thanks people!

_________________
You are wecome here, at my new site http://www.bpled.com


Top
 Profile  
 
 Post subject: Re: On page load, if cookie set then hide div?
PostPosted: Tue Jun 16, 2009 10:38 am 
Offline

Joined: Mon Nov 17, 2008 6:50 am
Posts: 7
Not sure if it's what you're after, but may something like this will help.

Code:
...
<script language="javascript">

function foo() {

   if(document.cookie != "" && document.cookie != null) {
      document.getElementById("d").style.visibility = "hidden";
      alert(document.cookie);
   } else {
      var ndate = new Date();
      ndate.setDate(ndate.getDate() + 1);
      document.cookie = "test=cookie;expires=" + ndate.toGMTString();
      document.getElementById("d").innerHTML = "no cookie";
   }
}

</script>
</head>
<body onload="foo()">
<div id="d"></div>
...


HTH


Top
 Profile  
 
 Post subject: Re: On page load, if cookie set then hide div?
PostPosted: Mon Jun 22, 2009 7:44 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
Hi Panzer,

One thing, please avoid using "language" attribute for your script tags. It's deprecated.

_________________
~ Get me some work, I do freelancing ~


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley