js 统计

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>js统计代码</title>

<script language="JavaScript">
<!--
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() + 365 * 24 * 60 * 60 * 1000)
var visits = getCookie("counter")
if (!visits)
	visits = 1
else
	visits = parseInt(visits) + 1
	//setCookie("counter", visits, now)
	document.write("您是第" + visits + "访客!")
// -->
</script>
<!--获得上级url-->
<script type="text/javascript">
document.write(document.referrer);
document.write(document.URL);
document.write(document.domain);
document.write(document.cookie);
document.write(document.lastModified);
document.write(document.title);
</script>


<!--页面停留了多少时间-->
<form name=forms>
<p>网页已运行:</p> 
<input type=text name=input size="12">
          <script language="javascript">
var second=0;
var minute=0;
var hour=0;
idt=window.setTimeout("interval();",1000);
function interval(){
second++;
if(second==60){second=0;minute+=1;}
if(minute==60){minute=0;hour+=1;}

document.forms.input.value=hour+"时"+minute+"分"+second+"秒";
idt=window.setTimeout("interval();",1000);}
</script>
</form>


<!--Js得到当前时间:-->
<SCRIPT LANGUAGE="JavaScript">
var myDate = new Date();
myDate.getYear();       //获取当前年份(2位)
myDate.getFullYear();   //获取完整的年份(4位,1970-????)
myDate.getMonth();      //获取当前月份(0-11,0代表1月)
myDate.getDate();       //获取当前日(1-31)
myDate.getDay();        //获取当前星期X(0-6,0代表星期天)
myDate.getTime();       //获取当前时间(从1970.1.1开始的毫秒数)
myDate.getHours();      //获取当前小时数(0-23)
myDate.getMinutes();    //获取当前分钟数(0-59)
myDate.getSeconds();    //获取当前秒数(0-59)
myDate.getMilliseconds();   //获取当前毫秒数(0-999)
myDate.toLocaleDateString();    //获取当前日期
var mytime=myDate.toLocaleTimeString();    //获取当前时间
myDate.toLocaleString( );       //获取日期与时间
if (mytime<"23:30:00"){
   alert(mytime);
}

</SCRIPT>

<!--Js获得ip地理位置-->
<script language="javascript" type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>
<script type="text/javascript">document.write("欢迎来自:"+remote_ip_info.country+remote_ip_info.province+remote_ip_info.city+"的朋友!");

</script>




你可能感兴趣的:(js 统计)