初学javascript之cookie篇(3)


<HTML>
  <head>
  <title>Homepage</title>
  </head>
  <body>
  <a href='http://www.thehungersite.com/'>Manual redirection<br></a>


  <a href="JavaScript:ResetCookie()">Cookie reset</a>

  <script language="JavaScript">
  <!--
  var bVisitedToday = false;

  var lastVisit = GetCookie("lastVisit");
  if (lastVisit != null)
  {
  lastVisit = 1 * lastVisit;
  var lastHere = new Date(lastVisit); 
  var rightNow = new Date();

  if(lastHere.getYear() == rightNow.getYear()
     && lastHere.getMonth() == rightNow.getMonth()
     && lastHere.getDate() == rightNow.getDate())
  {
     bVisitedToday = true;
    }
  }

  if(bVisitedToday == false)
  {
  setLastlastVisitCookie();
  window.location="http://www.thehungersite.com/"
  }
  else
  {
  //window.location="about:blank"
  }

  function getCookieVal (offset)
  {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
  }
  function GetCookie (name)

 

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3