1 html meta 字段实现
这种是最简单的。
跳转...content="3,url=IndexServlet" 中3是指延迟3秒。
2 js setTimout
通过setTimeout执行一个延迟函数来达到跳转的目的。
setTimeout(jump,3000);
function jump(){
window.location.href='IndexServlet';
}
3 js setInterval 实现页面显示倒计时
通过setInterval函数,来周期性的更新倒计时间,同时更新到页面。页面上的显示效果是3 2 1,然后跳转到index.html
3
setInterval(jump,1000);
var sec = 3;
function jump(){
sec--;
if(sec > 0){
document.getElementById('remainSeconds').innerHTML = sec;
}else{
window.location.href = 'index.html';
}
}
4 js setTimeout 实现页面显示倒计时
通过setTimeout 函数,来周期性的更新倒计时间,同时更新到页面。页面上的显示效果是3 2 1,然后跳转到index.html
3
var sec = 3;
function jump(){
sec--;
if(sec > 0){
document.getElementById('remainSeconds').innerHTML = sec;
setTimeout(this.jump,1000);
}else{
window.location.href = 'index.html';
}
}
setTimeout(jump,1000);