Cookie : Indication for New links or Message for User.

Use this cookie to show your visitors what's new on your Web site since their last visit.It is very basic   line of code written in java script . If you have basic knowledge of java script so you can do it easily . Click here to Download Demo .

 
Code:

  1. <html>
  2. <head>
  3. <script language="javascript">
  4. now = new Date
  5. expireDate = new Date
  6. expireDate.setMonth(expireDate.getMonth()+6)
  7. lastVisit = new Date(cookieVal("pageVisit"))
  8. document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString()
  9. function cookieVal(cookieName) {
  10.   thisCookie = document.cookie.split("; ")
  11.     for (i=0; i<thisCookie.length; i++) {
  12.       if (cookieName == thisCookie[i].split("=")[0]) {
  13.         return thisCookie[i].split("=")[1]
  14.       }
  15.     }
  16.   return "1 January 1970"
  17. }
  18. function newCheck(yyy,mm,dd) {
  19.   lastChgd = new Date(yyy,mm-1,dd)
  20.   if (lastChgd.getTime() > lastVisit.getTime()) {
  21.     document.write("<img src=http://2.bp.blogspot.com/-BH7YBcRMuWI/TkgXEI71ZfI/AAAAAAAAAFI/_I2y83xRNBI/s1600/new.gif' alt='new'>")
  22.   }
  23. }
  24. </script>
  25. </head>
  26. <body>
  27. <script type="text/javascript" language="JavaScript"> newCheck(2005,2,11)</script>
  28.  Be sure to check out our new scripts!
  29. <br>
  30. <script type="text/javascript" language="JavaScript"> newCheck(2005,2,3)</script>
  31. Have you seen our Tutorials?
  32. </html>


No comments:

Post a Comment

Comment On Facebook