My survey is set up to reset every time the participant leaves the survey or refreshes the page.
However, the devices these surveys will be set up on are quite finnicky, and it is easy to accidentally refresh the page or exit out of the current tab. In addition, most of our participants will be on the older side, so we want as many guardrails as possible to prevent them from unintentionally resetting the survey.
I’m wondering if there are any ways to detect page refresh or page close events on javascript, then have the following window pop up to simply ask them if they want to confirm their exit:
confirm("Are you sure you want to refresh/leave the page? All survey progress will be lost.");
My only problem is finding an event handler function to put this code into. I tried the addOnUnload function, but its not what I’m looking for since it only triggers when the Next button is clicked.
Any help is appreciated. Thank you.