车辆限号js代码

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/bingdongsanxian/article/details/54016841
<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /></head><body>
<style type="text/css"> 
.xianhao{color: #666666;font-family:simsun;font-size:14px;font-weight: bold;line-height:24px;}
.today,.todaynum,.tomorrow,.tomorrownum{color:red;}
.normal{font-weight:normal;font-size:12px;}
.normal a{color:#666666;text-decoration: none;}
</style>
 
<span id="sday" style="display:none">2014-01-08</span>
<div id="xianhao" class="xianhao">
<span class="today" id="todayweek"></span>&nbsp;限行尾号是:<span class="todaynum" id="todaynum"></span><br />
<span class="tomorrow" id="tomorrowweek"></span>&nbsp;限行尾号是:<span class="tomorrownum" id="tomorrownum"></span> 
<span class="normal"><a href="http://www.bjjtgl.gov.cn/zhuanti/10weihao/index.html" target="_blank">限行详情>></a></span>
</div>
<script type="text/javascript"> 
function getXHNumber(tDate,sDate)
{
var nDayNum = tDate.getDay() == 0 ? 7 : tDate.getDay();
if(nDayNum>5) return nDayNum;
var nDiff = (tDate - sDate)/1000/3600/24/7/13;
nDiff = Math.floor(nDiff) % 5;
nDayNum = 5 - nDiff + nDayNum ;
if(nDayNum>5) nDayNum -= 5;
return nDayNum;
}
//获取今天的日期
var dd = new Date();
var y = dd.getFullYear(); 
var m = dd.getMonth()+1;//获取当前月份的日期 
var d = dd.getDate();
if(m<10){
m="0"+m;
}
if(d<10){
d="0"+d;
}
var sday = y+"-"+m+"-"+d;


var sStartDate = '2016-07-11';//开始星期,周一的日期
var x1 = '1和6';
var x2 = '2和7';
var x3 = '3和8';
var x4 = '4和9';
var x5 = '5和0';
var x6 = '不限行';
var x7 = '不限行';
var arr1=sStartDate.split("-");
var vStartDate = new Date(arr1[0],arr1[1]-1,arr1[2]);
var arr2 = sday.split("-");
var vToday = new Date(arr2[0],arr2[1]-1,arr2[2]);
var nTodayNum = getXHNumber(vToday,vStartDate);
vToday.setDate(vToday.getDate()+1);
var nTomorrowNum = getXHNumber(vToday,vStartDate);
/***start week***/
var arr_week=new Array("星期六","星期日","星期一","星期二","星期三","星期四","星期五");
var todayweek=vToday.getDay();
document.getElementById("todayweek").innerHTML=arr_week[todayweek];
document.getElementById("tomorrowweek").innerHTML=arr_week[(todayweek+1)==7?0:todayweek+1];
/***end week***/
document.getElementById("todaynum").innerHTML = eval('x'+nTodayNum);
document.getElementById("tomorrownum").innerHTML = eval('x'+nTomorrowNum);
</script>
</body>

</html>


展开阅读全文

没有更多推荐了,返回首页