车辆限行提示JS代码(不含节假日)
温馨提示:文章已超过2143天没有更新,若内容或图片失效,请留言反馈!
<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">2019-05-23</span> <div id="xianhao" class="xianhao"> <span class="today" id="todayweek"></span> 限行尾号是:<span class="todaynum" id="todaynum"></span><br /> <span class="tomorrow" id="tomorrowweek"></span> 限行尾号是:<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 = '2019-05-20';//开始星期,周一的日期 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>
还没有评论,来说两句吧...