/**
* 页面动态显示系统时间
*/
function current() {
var d = new Date(), str = '';
var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五",
"星期六");
var week = arr_week[d.getDay()]; //获取中文的星期
str += d.getFullYear() + '年'; //获取当前年份
str += d.getMonth() + 1 + '月'; //获取当前月份(0——11)
str += d.getDate() + '日';
str += d.getHours() + '时';
str += d.getMinutes() + '分';
str += d.getSeconds() + '秒';
str += ' ' + week; //中文星期
return str;
}
setInterval(function() {
$("#nowTime").html(current)
}, 0);
页面定时跳转参考:http://blog.csdn.net/flywindmouse/article/details/17162043
<pre name="code" class="javascript">/**
* 动态倒计时页面跳转
*/
function countDown(secs, surl) {
var jumpTo = document.getElementById('jumpTo');
jumpTo.innerHTML = secs;
if (--secs > 0) {
setTimeout("countDown(" + secs + ",'" + surl + "')", 1000);
} else {
location.href = surl;
}
}
使用:
<pre name="code" class="html"><body>
<span id="nowTime" style="font-weight:bolder; "></span>
<h1>提交成功</h1>
<a href="index.jsp"><span id="jumpTo">10</span>秒后系统会自动跳转,也可点击本处直接跳</a>
<script type="text/javascript">
countDown(10, 'index.jsp');
</script>
</body>