初学Javascript之cookie篇(3),初学Javascript之cookie篇(3)
【 tulaoshi.com - Javascript 】
<html
<head
<titleHomepage</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)
来源:http://www.tulaoshi.com/n/20160129/1483305.html
看过《初学Javascript之cookie篇(3)》的人还看了以下文章 更多>>