脚本盲求一段JS代码:
要求:
1。显示网页在线人数;
2。显示并记录来访者IP;
3。网站自某日起的总访问量计数;
4。处理页面打开所花的时间。
感激不尽。。。谢谢。
---------------------------------------------------------------
JS 是不行的。
必须服务器端处理才能统计的。
---------------------------------------------------------------
这个你最好用asp好像js不能实现
---------------------------------------------------------------
是用JS调用asp等CGI程序的,如
1<script language="javascript" src="http://yourdomain/yourcgi.asp?op=1&t=2"></script>
http://yourdomain/yourcgi.asp?op=1&t=2这个需要分析数据,最后生成JS语法输入语句,document.write(*);
---------------------------------------------------------------
显示并记录来访者IP;
3。网站自某日起的总访问量计数;
js可以实现
---------------------------------------------------------------
//记录某人的访问量
1<html>
2<head>
3<title>Listing 25.2. Getting and Setting Multiple Cookies</title>
4</head>
5<body>
6<script language="JavaScript" type="text/javascript">
7<!--
8
9function get_cookie(name_to_get) {
10
11var cookie_pair
12var cookie_name
13var cookie_value
14
15// Split all the cookies into an array
16var cookie_array = document.cookie.split("; ")
17
18// Run through the cookies
19for (counter = 0; counter < cookie_array.length; counter++) {
20
21// Split the cookie into a name/value pair
22cookie_pair = cookie_array[counter].split("=")
23cookie_name = cookie_pair[0]
24cookie_value = cookie_pair[1]
25
26// Compare the name with the name we want
27if (cookie_name == name_to_get) {
28
29// If this is the one, return the value
30return unescape(cookie_value)
31}
32}
33
34// If the cookie doesn't exist, return null
35return null
36}
37
38// Get the user_name cookie
39var user_name = get_cookie("user_cookie")
40
41// Did the cookie exist?
42if (!user_name) {
43
44// If not, prompt for the name
45user_name = prompt("Please enter your first name:","")
46
47// Set the cookie
48document.cookie = "user_cookie=" + escape(user_name)
49}
50
51// Get the count cookie
52var visit_number = get_cookie("count_cookie")
53
54// Did the cookie exist?
55if (!visit_number) {
56
57// If not, then this is the user's first visit
58visit_number = 1
59document.writeln("Welcome " + user_name + ". This is your first visit.")
60}
61else {
62
63// Otherwise, increment the visit number
64visit_number++
65document.writeln("Welcome " + user_name + ". This is visit number " + visit_number + ".")
66}
67
68// Set the cookies
69document.cookie = "count_cookie=" + visit_number
70
71
72//-->
73</script>
74</body>
75</html>