java实现倒计时页面跳转

来源:互联网 发布:小来哥淘宝视频 编辑:程序博客网 时间:2024/04/26 14:36
 <script type="text/javascript">
  onerror=handler;
  var txt="";
  function handler(msg,url,line){//这个调试js错误
     txt="there are an error on the page.\n\n";
txt+="Error:"+msg+"\n";
txt+="url:"+url+"\n";
txt+="line:"+line+"\n";
alert(txt);
return true;
  }


 var second=document.getElementById("jumpTime").innerText; //jumpTime是html标签里的id 我一般用span大家可以用div,但div是块级元素注意使用
  setInterval("refn()",1000);
 function refn(){
document.getElementById("jumpTime").innerText=--second;
if(second<1)
{
   document.getElementById("jumpTime").innerText=0;
location.href="http://www.baidu.com";
}
 }
</script>
原创粉丝点击