Javascript variables in Storyline

Dec 31, 2015

Hello!

I'm having trouble referencing variables on frames that occur after they are declared. For example, on the first frame of a course, window.open on the last line successfully opens the window with passURL as the URL.

//Ask the LMS object to get the name
var rawName = lmsAPI.GetStudentName();
var rawID = lmsAPI.GetStudentID();
var Office = 0;
var Field = 0;
var Drive = 0;
var passURL = "https://thisURL.com/CompleteCourse/SafetyForLife?userid="+rawID+"&office="+Office+"&field="+Field+"&drive="+Drive;
window.open(passURL);

However, the following code on the next slide breaks JavaScript entirely so that no JS in the course works at all:

window.open(passURL);

If I replace the passURL with a regular URL on the second frame, the window opens and everything works. 

window.open("http://www.google.com");

What am I doing wrong? How can I successfully reference passURL (and all the variables in encompasses) from any frame in the course? Does it need a GetVar? (That doesn't seem to fix the problem, but maybe I'm doing it wrong.)

player.GetVar("passURL",passURL);
window.open(passURL);

Thank you!

3 Replies
Karessa Torgerson

This works!

//Ask for the Articulate player

var player1 = GetPlayer();

var urlID = player1.GetVar("rawID");
var urlOffice = player1.GetVar("Office");
var urlField = player1.GetVar("Field");
var urlDrive = player1.GetVar("Drive");

var passURL = "https://YOURURL.com/CompleteCourse/SafetyForLife?userid="+urlID+"&office="+urlOffice+"&field="+urlField+"&drive="+urlDrive;

window.open(passURL);

 

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