gpt4 book ai didi

javascript - 几秒钟后转到下一页

转载 作者:行者123 更新时间:2023-11-27 23:31:25 25 4
gpt4 key购买 nike

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

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

我试图将 javascript 放入 switch..case,

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

它直接将我带到下一页而不倒数。有什么解决办法吗?

最佳答案

可以使用php的header函数

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

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

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

},5000);

关于javascript - 几秒钟后转到下一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35545684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com