网页n秒后自动跳转
- 方式一:
中转页面 3秒之后自动跳转到res.html
- 方式二:
中转页面 onload=function(){ //在进入网页的时候加载该方法 setTimeout(go, 3000); //单位ms }; function go(){ location.href="res.html"; } //3秒之后自动执行go方法,直接跳转到index.jsp页面
- 方式三:
中转页面 onload=function(){ setInterval(go, 1000); }; var x=3; //利用了全局变量来执行 function go(){ x--; if(x>0){ document.getElementById("sp").innerHTML=x; //每次设置的x的值都不一样了。 }else{ location.href='res.html'; } } //3秒之后自动执行go方法,直接跳转到index.jsp页面
- 方式四:使用JQuery
中转页面 var timeID = 0; var timeLeft = 3; function count() { timeLeft--; $('#sp').text(timeLeft); if (timeLeft 3 //3秒之后自动执行go方法,直接跳转到index.jsp页面