jsp网页倒计时跳转页面

时间:2021-06-08 22:04:03
<span style="font-size:18px;"><%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<meta http-equiv='refresh' content='3;url=indexAction'><!--content='页面停留时间(这里单位是秒);url=跳转至另一页面'  -->
<script type='text/javascript'>
var i=3;
function getTime(){
document.getElementById('num').innerHTML="<font color='red'>"+i+"</font>";
i-=1;
var x=setTimeout('getTime()',1000)//1000毫秒=1秒
if(i<=0){
clearTimeout(x);
}
}
window.onload=getTime;//开始执行倒计时
</script>
<TITLE>${message}</TITLE></HEAD>
<BODY>
	<br>
	<center>
		<h2>
			${message}<br>
			注意!!页面将在<span id='num' style='display=inline;'>3</span>秒后跳转至主页
		</h2>
	</center>
</BODY>
</HTML> </span>