-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.html
110 lines (103 loc) · 3.53 KB
/
get.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<html>
<head>
<title>get</title>
</head>
<body>
<script src="save.js"></script>
<script>
var caution = false
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if (!caution || (name + "=" + escape(value)).length <= 4000)
document.cookie = curCookie
else if (confirm("Cookie exceeds 4KB and will be cut!"))
document.cookie = curCookie
}
function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length,
cookieEndIndex))
}
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT"
}
}
function fixDate(date) {
var base = new Date(0)
var skew = base.getTime()
if (skew > 0)
date.setTime(date.getTime() - skew)
}
var now = new Date()
fixDate(now)
now.setTime(now.getTime() + 730 * 24 * 60 * 60 * 1000)
var visits = getCookie("counter")
if (!visits)
visits = 1
else
visits = parseInt(visits) + 1
setCookie("counter", visits, now)
console.log("欢迎您,您是第:" + visits + " 个访问该站点的访客");
document.write("<font size=6 color=red>欢迎您,您是第:" + visits + " 个访问该站点的访客")
/*
function getQueryString() {
location.href.replace("#","");
// 如果链接没有参数,或者链接中不存在我们要获取的参数,直接返回空
if(location.href.indexOf("?")==-1) {
return '';
}
// 获取链接中参数部分
var queryString = location.href.substring(location.href.indexOf("?")+1);
// 分离参数对 ?key=value&key2=value2
var parameters = queryString.split("&");
var pos, paraName, paraValue;
for(var i=0; i<=parameters.length; i++) {
// 获取等号位置
if(undefined == parameters[i]){
continue;
}
pos = parameters[i].split('=');
if(pos == -1) { continue; }
// 获取name 和 value
paraName = pos[0];
paraValue = pos[1];
if(window.localStorage) {
// localStorge可用
// 获取本地存储对象
var localStorage =window.localStorage;
// 存储
localStorage.setItem(paraName,paraValue);
}else {
// localStorge不可用
console.log("localStorge is false");
}
// 如果查询的name等于当前name,就返回当前值,同时,将链接中的+号还原成空格
if(paraName == name) {
return decodeURIComponent(paraValue.replace(/\+/g, " "));
}
}
//return '';
}
//调用方法
getQueryString();
console.log(localStorage.getItem("time"));
console.log(localStorage.getItem("stop"));
//localStorage.clear();
*/
</script>
</body>
</html>