我只是在寻找一个简单的定时器,在那里我能得到我的网页在30秒后运行的脚本。
I'm just looking for a simple timer, where I can get my page to run a script after 30 seconds.
我们的想法是,用户有30秒的时间提交答辩,否则页面将运行一个脚本,并带他们到一个对不起,太慢了风格的页面。
The idea is that the user has 30 seconds to submit an answer, otherwise the page will run a script and take them to a 'sorry, too slow' style page.
我无法找到正确的PHP函数,但它基本上我们是这样的:
I cannot find the correct php function for this, but it basically we be like:
<?php
Start timer(30);
when timer runs out:
header("location: tooslow.php");
?>
感谢您的帮助, 布雷特
Thanks for any help, Brett
您可以在Javascript中使用的setTimeout()做到这一点;
You could do this in Javascript using setTimeout();
var t=setTimeout("killPage",30*1000);
function killPage(){
window.location='/fail.php';
}
function questionComplete(){
t.clearTimeout();
}