| Member List |
| Posted: 11 Nov 2006 15:45 | ||
|
|
Registered User Currently Offline |
Posts: 69 Join Date: Nov 2006 |
|
Using cookies, this script records the date+time of your visitor's last visit and displays it upon their return. If this is their first visit to your site, a greeting message is shown instead.
Code: <script type="text/javascript"> var lastvisit=new Object() lastvisit.firstvisitmsg="This is your first visit to this page. Welcome!" //Change first visit message here lastvisit.subsequentvisitmsg="Welcome back visitor! Your last visit was on <b>[displaydate]</b>" //Change subsequent visit message here lastvisit.getCookie=function(Name){ //get cookie value var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return "" } lastvisit.setCookie=function(name, value, days){ //set cookei value var expireDate = new Date() //set "expstring" to either future or past date, to set or delete cookie, respectively var expstring=expireDate.setDate(expireDate.getDate()+parseInt(days)) document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/"; } lastvisit.showmessage=function(){ if (lastvisit.getCookie("visitcounter")==""){ //if first visit lastvisit.setCookie("visitcounter", 2, 730) //set "visitcounter" to 2 and for 730 days (2 years) document.write(lastvisit.firstvisitmsg) } else document.write(lastvisit.subsequentvisitmsg.replace("\[displaydate\]", new Date().toLocaleString())) } lastvisit.showmessage() </script> __________________ my own tutorial website... i love it... yeah i really do. marry me ..
http://www.tutorials-expert.com |
||
| Posted: 12 Nov 2006 12:21 | ||
|
Administrator Currently Offline |
Posts: 157 Join Date: Oct 2006 |
|
|
Wow that actually might come in handy.
Did you write this all by yourself? __________________ ![]() |
||
| Posted: 12 Nov 2006 20:49 | ||
|
|
Registered User Currently Offline |
Posts: 69 Join Date: Nov 2006 |
hmm not actually all by myselfm used a little help of my brother and the net. ![]() __________________ my own tutorial website... i love it... yeah i really do. marry me ..
http://www.tutorials-expert.com |
||