Skip to content

Instantly share code, notes, and snippets.

@sumaolin
Created September 24, 2013 07:40
Show Gist options
  • Save sumaolin/6681540 to your computer and use it in GitHub Desktop.
Save sumaolin/6681540 to your computer and use it in GitHub Desktop.
javascript 定时器 倒计时 From http://www.tuicool.com/articles/ZbeQZj
<script type="text/javascript">
var start = 5;
var step = -1;
function count()
{
document.getElementById("div1").innerHTML = "页面将在"+start+"秒后返回登录页面...";
start += step;
if(start <= 0){
start = 5;
//window.location="index.jsp";//返回index.jsp页面
//TODO:在这里可以做相关的操作
}
setTimeout("count()",1000);
}
window.onload = count;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment