#1 by lianfeng
hey, I designed my time-out, here is the code: function Countdown(remainingTime) { let countdownElement = document.getElementById('countdown'); countdownElement.innerText = remainingTime; let intervalId = setInterval(function () { remainingTime -= 1; countdownElement.innerText = remainingTime; if (remainingTime <= 0) { clearInterval(intervalId); window.location.href = '/next/page' } }, 1000); } document.addEventListener('DOMContentLoaded', function () { let remainingTime = 1200; Countdown(remainingTime); }); then how to redicted it to the 'ResultsWaitPage' when time has out? i mean i don't know the url of it. thanks for all response!
#2 by BonnEconLab
I don’t think that implementing a timeout via JavaScript is a good idea. The reason is that participants can reset the timer by simply refreshing the page. Why don’t you use oTree’s built-in timeout method, that is, adding timeout_seconds = 1200 to your page class? For details, see https://otree.readthedocs.io/en/latest/timeouts.html. After the timeout, the player will advance automatically to the next page. If you would like to direct participants who reached the timeout to a different page, you can use before_next_page to achieve this.
#3 by lianfeng
well, i have tried it several days ago, but the fixed style of oTree’s built-in timeout method is not suitable to my page. i also tried to modify its style, but failed. so, is there any method to change its style? the information in the docunment didn't help me a lot. thanks for your last answer! and i expect to receive another one.
#4 by lianfeng
well, finally ,it seems that my coding skill required to be improved. I have successfully finished my coding with otree. btw, the time out in fact can be modified to other styles. Failing to modify it was my problem. thanks for your help again! and happy new year! l.f. 2023.12.31