html页面在一段时间后重定向到他要求的内容

时间:2016-04-08 09:44:35

标签: redirect

如何创建10秒倒计时的HTML等待页面,然后转移到请求的页面(showthread.php) 例如有人要求下载下面的附件文件我需要客人或会员等待一段时间然后重定向到他要求的内容 http://shneler.com/vb/showthread.php?t=46900

1 个答案:

答案 0 :(得分:0)

编辑:setTimeout立即返回,这是完全错误的。这虽然有效:

function displayTime(time, node) {
    if(time < 1) {
    window.location.href="https://wikipedia.org/";
  } else {
    node.textContent = time;
  }
}
document.addEventListener("DOMContentLoaded", function(event){
  node = document.getElementById("time");
  var time = 10;
  setInterval(function(){time -= 1; displayTime(time, node);}, 1000);
});

您甚至可以在此处看到它:https://jsfiddle.net/perfectfire/n6cv5hvr/