<span style="white-space:pre"> </span><tr>
<span style="white-space:pre"> </span><td height="25" align="right" class="white_word">
<script language="JavaScript" type="text/javascript">
//以下是年月日星期显示
tmpDate=new Date();
date=tmpDate.getDate();
month=tmpDate.getMonth()+1;
year=tmpDate.getYear();
document.write("<span><img src='images/clock.gif' width='16' height='16' /></span>当前时间:"+year);
document.write("年");
document.write(month);
document.write("月");
document.write(date);
document.write("日 ");
myArray=new Array(6);
myArray[0]="星期日 "
myArray[1]="星期一 "
myArray[2]="星期二 "
myArray[3]="星期三 "
myArray[4]="星期四 "
myArray[5]="星期五 "
myArray[6]="星期六 "
weekday=tmpDate.getDay();
if(weekday==0|weekday==6)
{
document.write(myArray[weekday]+' ')
}else{
document.write(myArray[weekday]+' ')
};
function changePass(){
var url = '<%=request.getContextPath()%>/changePass.jsp';
window.location.href(url);
}
</script>
</td>
<span style="white-space:pre"> </span></tr>
<tr>
<span style="white-space:pre"> </span><td height="25" align="right" class="white_word">
<script language="JavaScript" type="text/javascript">
document.write("<span><img src='images/clock.gif' width='16' height='16' /></span >时间倒计时:");
document.write("<span id='t_d'>00天</span>");
document.write("<span id='t_h'>00小时</span>");
document.write("<span id='t_m'>00分钟</span>");
document.write("<span id='t_s'>00秒</span>");
function countTime(){
//var EndTime = document.getElementById("endtime1").value;
var EndTime1= new Date('2015/10/23 16:06:50'); //截止时间
var NowTime = new Date();
//var EndTime1 = new Date(EndTime.replace(/-/g, "/"));
var t =EndTime1.getTime() - NowTime.getTime();
var d=Math.floor(t/1000/60/60/24);
var h=Math.floor(t/1000/60/60%24);
var m=Math.floor(t/1000/60%60);
var s=Math.floor(t/1000%60);
document.getElementById("t_d").innerText = d + "天";
document.getElementById("t_h").innerText = h + "时";
document.getElementById("t_m").innerText = m + "分";
document.getElementById("t_s").innerText = s + "秒";
if(s==0&&m==0&&h==0&&d==0)
{
var form=document.getElementById("formToor");
alert("试用结束!谢谢使用!");
parent.location.href = "login.jsp";
}
}
setInterval(countTime,1000)
</script>
</td>
<span style="white-space:pre"> </span></tr>
使用js在页面增加倒计时功能和显示年月日星期
最新推荐文章于 2024-06-24 19:57:36 发布