Is it possible to pass variables into an instance of a Storyline course when it starts up - eg. to toggle a Boolean which shows/ hides a certificate page?
function getQueryVal(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length;i++){
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
}
var player=GetPlayer();
//storyline variables userName and userID must exist for this to work
player.SetVar("userName", getQueryVal("userName"));
player.SetVar("userID",getQueryVal("userID"));
It uses "?" as a separator, and you append variables to the URL query. If
you need any help with it let me know. I had to repair the "for" loop
because on the original it had erased some of it on posting, so hopefully
this will remain in tact.
3 Replies
I need to know this also.
I've actually found this on another thread.
You can! The code is as follows:
function getQueryVal(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i = 0; i < vars.length;i++){
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
}
var player=GetPlayer();
//storyline variables userName and userID must exist for this to work
player.SetVar("userName", getQueryVal("userName"));
player.SetVar("userID",getQueryVal("userID"));
It uses "?" as a separator, and you append variables to the URL query. If
you need any help with it let me know. I had to repair the "for" loop
because on the original it had erased some of it on posting, so hopefully
this will remain in tact.
Oh - thanks Matthew Bibby, just saw your reply.
This discussion is closed. You can start a new discussion or contact Articulate Support.