正在阅读:初学Javascript之cookie篇(译)初学Javascript之cookie篇(译)

2004-02-14 09:34 出处:PConline 作者:yjgx007编译/CSDN 责任编辑:linjixiong

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

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品