首页 > Web开发 > 详细

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

时间:2015-03-07 18:22:19      阅读:371      评论:0      收藏:0      [点我收藏+]

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>

  实用的话,还得再改改。

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

原文:http://www.cnblogs.com/TeaIng-Index/p/4320696.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!