Forum Discussion
Using a JS command to jump to a specific slide after a JS request.
Hi Anne-Laure,
I've looked into using JavaScript to navigate to a slide in the past, and there isn't an API exposed for this. The best solution I came up with was using JavaScript to get my value, in your case language. Then using that value, set a variable value in Storyline. You can then have a trigger in Storyline that jumps to a particular Scene/Slide when the variable changes, and based on the value.
For example:
The following JS could run on a button click, or on slide load. Whatever trigger is needed
getLanguage = function()
{
// magic happens that gets the language from the LMS
return API.LMSGetValue("cmi.student_preference.language");
}
let JSuserLang = getLanguage(); // returns "en", "es-ES", "fr";
// get the Storyline Player API
const SLPlayer = GetPlayer();
// set a Storyline variable named 'userLang' to the value JSuserLang
SLPlayer.SetVar('userLang', JSuserLang);
Then, within Storyline you have a trigger:
Jump to slide 1.2 when variable changes "userLang"
if "userLang" === "fr"
Jump to slide 1.3 when variable changes "userLang"
if "userLang" === "en"
Jump to slide 1.4 when variable changes "userLang"
if "userLang" === "es-ES"
Related Content
- 3 months ago
- 11 months ago