#1 by Mike_Zhiren_Wu
Hi Chris and all, Currently I'm trying to get the time usage data on every single page and give it to subjects as periodic feedback. I find a usable code in the forum while the timer is reset to 0 if I refresh the current page so that the response time is not correctly recorded. I just wonder if there are other ways to achieve this so that the response time can be fully saved even if there can be potential refreshing issue if I run the experiment online. The script I am currently using is as follows: <script> //This bit creates 2 variables, one will function as a timer, the other will hold the timer output. They are set to 0 and -1 here to initialise them, these will not be the final outputs. var pageTimeElapsed = 0; var pageTimerID = -1; //This function captures the timer output. When the timer starts it will increase 'pageTimeElapsed' every second and send this value to the 'timeSpent' variable that will be saved //When a person moves to the next page, or the page times out, the final value that the timer was on will be saved. The value resets each round/page. function pageTick() { pageTimeElapsed++ document.getElementById("timeSpent_easy1").value = pageTimeElapsed; } //This function automatically starts the timer when the page loads. In this case I want seconds so the interval is set to 1000, but I believe if you set it to 1 then it will count milliseconds - you will need to test this window.onload = function() { if(pageTimerID == -1){ pageTimerID = setInterval(pageTick, 1000); } }; </script>