//页面解析到当前为止所有的script标签 var count = document.scripts; //js[js.length - 1] 就是当前的js文件的路径 count = count[count.length - 1].src.substring(0, count[count.length - 1].src.lastindexof("/") + 1); var $_get = (function(){ var url = document.scripts[document.scripts.length - 1].src; var u = url.split("?"); if(typeof(u[1]) == "string"){ u = u[1].split("&"); var get = {}; for(var i in u){ var j = u[i].split("="); get[j[0]] = j[1]; } return get; } else { return {}; } })(); //var site_id=$_get["id"]; var countpage = count + 'count.php'; var pageurl = escape(top.location.href); var referer = escape(top.document.referrer); var language = (navigator.systemlanguage?navigator.systemlanguage:navigator.language); var color = screen.colordepth; var screensize = screen.width + '*' + screen.height; var charset = document.charset; var title = document.title; //首次访问时间和最后访问时间 var firsttime; var lasttime; firsttime = readcookie( 'firsttime' ); if( firsttime == '' ) { firsttime = gettime(); lasttime = firsttime; writecookie( 'firsttime', firsttime, 10000 ); } else { lasttime = gettime(); } //访问次数 returncount = readcookie( 'returncount' ); returncount = returncount == '' ? 0 : returncount; returntime = readcookie( 'returntime' ); if( returntime == '' ) { returntime = gettime(); writecookie( 'returntime', returntime, 10000 ); } temp = returntime.split( '-' ); returntimedate = new date(temp[0], temp[1]-1, temp[2], temp[3], temp[4], temp[5] ); nowtimedate = new date(); if( nowtimedate - returntimedate >= 43200000 ) { writecookie( 'returncount', ++returncount, 10000 ); writecookie( 'returntime', gettime(), 10000 ); } else { returncount = null; } var counturl = countpage + '?' + 'act=statistic' //+ '&site_id='+site_id //+ '&counturl=' + count + '&title=' + title + '&pageurl=' + pageurl + '&referer=' + referer //+ '&language=' + language //+ '&color=' + color //+ '&screensize=' + screensize //+ '&firsttime=' + firsttime //+ '&lasttime=' + lasttime //+ '&charset=' + charset //+ '&timezone=' + (new date()).gettimezoneoffset()/60; if( returncount != null ) { counturl += '&return1=' + returncount; } console.log(counturl); document.write(''); //当前时间 function gettime() { now = new date(); year=now.getfullyear(); month=now.getmonth()+1; day=now.getdate(); hour=now.gethours(); minute=now.getminutes(); second=now.getseconds(); return year+"-"+month+"-"+day+"-"+hour+"-"+minute+"-"+second; } //读取cookie function readcookie(name) { var cookievalue = ""; var search = name + "="; if(document.cookie.length > 0) { offset = document.cookie.indexof(search); if (offset != -1) { offset += search.length; end = document.cookie.indexof(";", offset); if (end == -1) end = document.cookie.length; cookievalue = unescape(document.cookie.substring(offset, end)) } } return cookievalue; } //写入cookie function writecookie(name, value, hours) { var expire = ""; var current_time=new date().gettime(); if(hours != null) { expire = new date(current_time + hours * 3600000); expire = "; expires=" + expire.togmtstring(); } document.cookie = name + "=" + escape(value) + expire + "domain=;" + "path=/;"; }