用计时器重定向

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用计时器重定向相关的知识,希望对你有一定的参考价值。

You can use javascript window.location to redirect a visitor to a required page. You may have seen this feature used by sites with full page ads, or to redirect visitors to the site's new domain name. You can add also a timer to the script that will allow the page to redirect and the visitors will not need to click a link or type in the new URL.
  1. <script type="text/javascript">
  2. var count = 6;
  3. var redirect = "http://www.apphp.com";
  4.  
  5. function countDown(){
  6. var timer = document.getElementById("timer");
  7. if(count > 0){
  8. count--;
  9. timer.innerhtml = "This page will redirect in "+count+" seconds.";
  10. setTimeout("countDown()", 1000);
  11. }else{
  12. window.location.href = redirect;
  13. }
  14. }
  15. </script>
  16.  
  17. Our webpage has beed moved. Please update your bookmarks for the new site.
  18. <br>
  19.  
  20. <span id="timer">
  21. <script type="text/javascript">countDown();</script>
  22. </span>

以上是关于用计时器重定向的主要内容,如果未能解决你的问题,请参考以下文章

Yii2 使用计时器重定向

代码点火器重定向()在 IE9 中不起作用

从 servlet 过滤器重定向到 jsf 会返回未呈现为 html 的实际 jsf 代码

ios如何将自定义控制器重定向obj-c代码放在自定义视图中

获取“java.net.ProtocolException:服务器重定向太多次”错误

如何在 IOS 应用程序中从视图控制器重定向回主故事板