Force JavaScript to stop executing on a given slide
First disclaimer: I’m brand new to JavaScript, so I’m learning as I go.
I have an assessment in Storyline 360 with a single “Submit” button at the end. I’m using JavaScript to provide a warning to users that if they exit their course before completing it, their answers will not be saved.
I’m using the following JS and it’s working as expected:
window.onbeforeunload = function() {
return “Are you sure you want to leave? Your progress will not be saved.”;
}
Now I’d like to stop it from executing on the final slide. Does anyone have suggestions?
Many thanks from a JS Newbie!
You could just add a boolean Storyline variable (e.g., showWarning) and set it to false on the slide where you don’t want the warning to show. The event handler will check it before triggering the dialog.