Pass variable value from story.html to storyline file

Hi,

How can I pass a variable value from the story.html to the storyline file?

I have tried putting this function in the head of the story.html file ...

<script>
function story() {
var player = window.parent.GetPlayer();
var testvar= 1;
player.SetVar("testvar",testvar);
}</script>

...and putting an onload="story()" in the body, but thats not working, any ideas?

Thanks
Gary

1 Reply
Gary Keogh

OK so i figured out how to do this thanks to Niels van Drimmelen

https://community.articulate.com/discussions/articulate-storyline/loading-an-external-javascript-library-per-slide

I added the following javascript to an 'Execute Javascript' Trigger when the first slide timeline starts.

var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src = 'story_content/spl.js';
script.type = 'text/javascript';
head.appendChild(script)

Then placed the file spl.js into the published "story_content" folder with the following JavaScript:

var SP_Assess_Included = 0;
var player = GetPlayer();
player.SetVar("assmnt",SP_Assess_Included);

Then i was able to alter the value of SP_Assess_Included after the lesson was published and the value could then be passed into the STORYLINE file at runtime, and most importantly altered without having to republish the storyline file.