Forum Discussion
KeithShull_VO
8 months agoCommunity Member
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...
- 8 months ago
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.
window.onbeforeunload = function(e) { //The newer approach //if (GetPlayer().GetVar("showWarning")) e.preventDefault(); //or the legacy approach (can use both to cover all possibilities) return GetPlayer().GetVar("showWarning") ? true : null; }
Nathan_Hilliard
8 months agoCommunity Member
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.
window.onbeforeunload = function(e) {
//The newer approach
//if (GetPlayer().GetVar("showWarning")) e.preventDefault();
//or the legacy approach (can use both to cover all possibilities)
return GetPlayer().GetVar("showWarning") ? true : null;
}