Can I call a Javascript function on the Slide Master from a slide
I have a trigger attached to the slide start timeline event on the Slide Master. the trigger "executes" a Javascript function.
function sayIt (message){
alert(message);
}
On one of the content slides I have a graphic that also has a trigger set to the start timeline event for that graphic
sayIt("this is the message")
But the alert message never appears.
I noticed the two javascript calls are encapsulate into other functions (script1 and script2) within the user.js file that Storyline creates. Do I need to move my function outside of this wrapper?
3 Replies
The scope is unreachable since the function is called within another function. To reach it you'll need to declare your function at a higher level. Try this on your master:
window.sayIt=function(message){
alert(message);
}
This should declare your function with a scope hoisted to the top.
Thanks, Steve! Just curious I read that jQuery is part of the Storyline javascript engine. Could I also attach my function to the jQuery object $. ?
You might be able to do that for the HTML5 output. Won't work at all for the Flash output since the library isn't loaded.