Storyline Player Javascript interaction

Jun 19, 2013


So I'm working with Javascript to create custom functionality in my slides.  

I have gone over the best practices here:

This give several good examples of javascript functions but I am unsure of what the api for the articulate player is and what all I can access.

Specifically I would to access some sort of seekTo(Time) type function.

Is there something similar to either of these out there?



82 Replies
Dave Cox

Hi Stephanie,

In the top line of your code, you declare the var scoreReportjs and retrieve the valuse from the articulate player. Once you declare a variable, you don't want to use the var keyword with it again. Remove the "var" keyword from the lines in your if then else statement. Declaring that as a variable again inside the if then statement causes javascript to treat it as a new local variable, and the contents of the original variable is ignore.

After you update the value of your variable with your if then statement, you need to update the articulate playe variable. To update your the articulate variable your statement needs to tell articulate when variable to update. Try this statement:


Another thing you can do to help debug your code, is to press F12 while the player is in your browser to open the developer tools. Select the console tab and view any javascrtip errors that may have occured. This will help you narrow the problem down in your code.

I hope this helps,


Dave Cox

Dave Cox

Sometimes it helps to get it down to the simplest actions, and then build from there. 

Try changing your last line to:


This should set your value to 1.

If that doesn't work, try:

GetPlayer().SetVar("scoreReport", 1);

Make sure the variable name of your variable in the course matches the variable name that you use here, including capitalization. Javascript interprets upper and lower case as different letters.

Also, I'm assuming the your variable is numeric? If it is text, change the statement to:

GetPlayer().SetVar("scoreReport", "1");

If you can get this statement to work, then you can go back and work out the rest of your code.

If you still can't get it to work, if you can post your project here I can take a look at it for you.



Dave Cox

If you declare a variable inside a function, it will be local to the function. If you declare it outside of the function, it will be global. Also, any variable that you declare in the variables panel in the storyline story will be global to both storyline, and to your javascript. 

If you are writing your javascript wholly within the trigger dialoge, I don't know think the variable will persist from one trigger to the next, but I haven't verified it. I suggest if you are doing this, store your variable in the storyline variables using setVar().

Crystal Horn

Hi Marisa!  I'm so glad the community helped you out here!  We support the published output without any modifications so that we can be sure that every feature of your course works well.  Fortunately, the forums have a wealth of information, especially when it comes to workaround and modifying your output.  Happy to see that these older threads are still beneficial.

James HIll

I know this is an old thread, but it seems like the topic I'm looking for. We're trying to access a storyline variable in javascript. I've tried the above with player.getVar and var p = getPlayer().getVar

But it tells me that getPlayer is undefined, getVar I can't find as a function in the js files, and also player is undefined.

Is this feature not available anymore (we have storyline 2).

Leslie McKerchie

Hi Christian,

The reply by Mark is a bit dated and I'm not sure if he's still subscribed here.

JavaScript is certainly not my specialty, but we have some brief documentation here related to Storyline 360. 

Please feel free to share what you would like to accomplish and I'm sure someone in the community can pop in to assist.

Dave Cox

Hi Ravindra,

So far, since I've been back using Storyline 360, I've found that my javascript scripts work just the same as the did in Storyline 3. I generally try to keep any code that I create within the constraints of the javascript window within storyline. This keeps the code with the source file, and automatically publishes with the project. Adding code after publishing is generally not a good practice.

Dave Cox

Ah! here lies the issue. 

Although you are coding in Javascript, player.restart is not a javascript method. It is a Storyline method that you are attempting to call via the GetPlayer interface. In fact, I suspect it was a method that was used to reset the Flash player that was part of Storyline 2. The Storyline player had to be completly rebuilt for HTML5. I suspect that the restart method was not implemented in the HtML5 player, and therefore is failing to run when you attempt to call it.

What is it you are attempting to accomplish? I'd be willing to bet that there is another way to do what you were trying to do. I beleive that the restart method took you back to frame 0 in the flash file. You can pretty much accomplis the same thing by providing a link back to slide 1 in your project. If you need to reset variables or quiz results, you might want to do this on a special slide with triggers to initialize your variables and reset the quiz, then navigate back to slide 1. 

There are a lot of things you can do with javasccript that can greatly enhance your storyline project. At the same time, I a big advocate of using javascript only when there is no other way do what you need to do directly from within Storyline. This prevents a lot of compatability issues, and makes the project easier to maintain.

I hope this helps. If you are still having issues, maybe you could share a little more about what it is you want to accomplish, and someone here can help you to find a way to do it.


This discussion is closed. You can start a new discussion or contact Articulate Support.