JS基于时间戳写的浏览访问人数

Title:JS基于时间戳写的浏览访问人数  --2013-12-23 14:07

<script language="JavaScript">
 var timestamp,timetmp,rand;
 rand = Math.floor(Math.random()*10); //随机数
 timestamp = new Date().getTime().toString(); //时间戳
 timetmp = (parseInt(timestamp)/1000/60).toString(); //截取长度+随机数
 timetmp = timetmp.substring(2,8);
 timetmp = (parseInt(timetmp)-120000).toString();
 if(timetmp.length==4){
  timetmp = "00"+timetmp;
 }else if(timetmp.length==5){
  timetmp = "0"+timetmp;
 } 
 var aa = $(".rs_A");
 for(var i=0; i < timetmp.length; i++){
  aa[i].innerHTML = timetmp.substr(i,1);
 }
 </script>

  最后给LI标签赋值

<script language="JavaScript">
var timestamp,timetmp,rand;
rand = Math.floor(Math.random()*10); //随机数
timestamp = new Date().getTime().toString(); //时间戳
timetmp = (parseInt(timestamp.substr(5,6))+rand).toString(); //截取长度+随机数
document.write("时间戳:"+timestamp);
document.write('</br>');
document.write("随机数:"+rand);
document.write('</br>');
document.write("访问量:"+timetmp);
</script>

  实用的话,还得再改改。

posted on 2015-03-07 17:38  Tea_Ing  阅读(532)  评论(0编辑  收藏  举报

导航