The problem: I created a website which requires the user to watch an animation for five minutes without doing anything else, ie touch the screen. This works just fine on a desktop computer, but mobile is a different story. When sleep mode is set to be activated in less than 5 minutes, it interrupts the script and the user has to start anew. I was convinced that there was no way to stop the screensaver from appearing but, as it turns out, there actually is: there is a neat javascript trick to prevent the screensaver from appearing!
The solution: attempt a redirect but stop it from actually happening:
iosSleepPreventInterval = setInterval(function () {
window.location.href = the_path;
window.setTimeout(function () {
window.stop()
}, 0);
}, 30000);
Thanks a lot for Stackoverflow!