在此秒后转到下一页

Go to next page after this seconds

本文关键字:一页      更新时间:2023-09-26

我一直在寻找一个简单的代码,但我没有找到适合我的代码。我尝试使用setInterval,但结果代码效果不佳。

<?php switch(n){ case 1: //do this; //then go to next page after this seconds; } ?>

我试图将javascript放入开关中。箱

echo "<script type='text/javascript'>setInterval(location.href = 'goHere.php', 3000);
</script>"

它引导我进入下一页而不倒计时。有什么解决办法吗?

你可以使用 PHP 的标头函数

header( "refresh:5;url=wherever.php" );

如果你想使用javascript,那么你可以使用setTimeout

setTimeout(function () {
   window.location.href= 'http://www.google.com'; // the redirect goes here
},5000);