Forum Discussion

KeithShull_VO's avatar
KeithShull_VO
Community Member
8 months ago
Solved

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...
  • Nathan_Hilliard's avatar
    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;
    }