学院首页>网页制作>Javascript>初学Javascript之cookie篇(3)

初学Javascript之cookie篇(3)

作者: 来源: 添加时间:2006-5-25 18:13:42

<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)


站内搜索