Javascript events in Storyline

Mar 09, 2024

Hi all,

I am trying to send a custom javascript event from an embedded storyline web object to storyline. I would like to listen for this event in a javascript trigger.

However, I am unable to hear my dispatched event.
Is there anyone with some javascript knowledge or a dev who can help me out?

The thing is, I AM able to listen for standard events like localstorage changes but it would be much easier if I could skip storing a variable in localstorage.

Anyway, I would appreciate some help as I have been searching the whole day :D

3 Replies
Sam Hill

Hi Bart,

One way you can get Storyline to react to an event from JavaScript in a WebObject is to change a variable value in your Storyline file.

You could have a variable called "listener" (type text) in Storyline. You can then update the value of this variable from your WebObject:

// Get reference to storyline player
// using parent, as a WebObject is in an iframe
const player = parent.GetPlayer();
player.SetVar("listener", "dosomething");


Then in Storyline, you can set-up a trigger that reacts when the variable "listener" is changed, for example:

Jump to slide next slide
When the variable changes
listener

If listener = value "nextslide"

One thing to look out for though, is sending multiple "nextslide" values to the variable will not trigger a change, as it is the same value. You would always have to set your variable back to "(blank)" to ensure that each event, is a variable value change.

Will that help with your situation Bart?