JS :3秒后自动跳转功能

简单实现:

function jump(){

        window.location.href='1.html';
    }
    setTimeout(jump, 3000);

动态的实现:

 <span id="cnt">4</span>秒钟后将自动跳转到首页...
  <script> var counter = 3; var timer1 = null; function jump(){ if(counter>=0){ document.getElementById('cnt').innerHTML = counter; counter--; }else{ clearInterval(timer1); location.href='1.html'; } } timer1 = setInterval(jump, 1000); </script>

你可能感兴趣的:(js)