I try to develop online exam app with JSP.So I want to link result page with parameters of existing page(exam page) when time runs out. I want to know how to add timer and link another page when time is up.
+3
A:
You need to use Javascript to achieve this. There you'll need to create a JS segment looking something like this:
<script type="text/javascript">
var myTimer = window.setTimeout(timer, 3000);
function timer() {
window.location.href = "new_page.htm"
}
</script>
That script is meant for going into the body section to work. A script for your head section would require an onload event to take care of starting the timer. The example will redirect after 3 seconds.
Per Stilling
2009-02-13 08:44:13
you *really* need to store the timer so you can cancel it, and a simple function reference will suffice - avoid evals where possible (edited)
annakata
2009-02-13 10:43:52
+1
A:
JavaScript is only client-side, it could be disabled or changed to cheat your application.
You have to keep track of the time at the server too, and you should also try to get input asap to your application, to know if the answer was "in time" or not.
Heavy AJAX is the way I would solve this problem.
Another way could be a Flash/Flex combo with a similar backend.
Karsten
2009-02-13 08:53:04