I have a page in a course (we'll call it the container) that I want to place a web object. That web object will be a second course (we'll call that one contents) (it's on the same domain). I need to have the contents change a variable in the container. I know I'll need to use Javascript to do this but it will have to work in both the flash and HTML5 versions. Has anyone had any luck in getting something like this to work?
If I interpreted your question correctly, you need to add JS code to the contents file you are to reference in your webobject (i.e. the JS trigger inside Storyline may not be needed).
You should be able to do this using GetVar (optional), changing the value of the variable in contents, then finally registering the change using SetVar.
The key part for the above to work is to use parent.GetPlayer() instead of just var player = GetPlayer();
Hi, Michael -- Thanks for reaching out, and while we are not able to provide support for JS coding, I see that Alexandros has stopped in to assist. Please be sure to share an update if you're all set, or if you had something else in mind, hopefully others can share additional insights. :)
Thanks Alexandros and Christie. I was able to get it to work in the web version using
var player=parent.GetPlayer(); player.SetVar("varname","true");
But using the same course published to the LMS and tested the communication between the content and the container never happens. While the web object loads fine, the javascript isn't able to communicate with the parent. Any idea on why this will happen?
Hi, Michael -- Unfortunately, JS is not in my wheelhouse, so I will need to defer to Alexandros or others in the community who are knowledgeable with JavaScript to assist you further.
7 Replies
Hi Michael,
If I interpreted your question correctly, you need to add JS code to the contents file you are to reference in your webobject (i.e. the JS trigger inside Storyline may not be needed).
You should be able to do this using GetVar (optional), changing the value of the variable in contents, then finally registering the change using SetVar.
The key part for the above to work is to use parent.GetPlayer() instead of just var player = GetPlayer();
Hope this helps,
Alex
Hi, Michael -- Thanks for reaching out, and while we are not able to provide support for JS coding, I see that Alexandros has stopped in to assist. Please be sure to share an update if you're all set, or if you had something else in mind, hopefully others can share additional insights. :)
Thanks Alexandros and Christie. I was able to get it to work in the web version using
var player=parent.GetPlayer();
player.SetVar("varname","true");
But using the same course published to the LMS and tested the communication between the content and the container never happens. While the web object loads fine, the javascript isn't able to communicate with the parent. Any idea on why this will happen?
Hi, Michael -- Unfortunately, JS is not in my wheelhouse, so I will need to defer to Alexandros or others in the community who are knowledgeable with JavaScript to assist you further.
Thanks Christie. Still looking for an answer.
Michael, have you checked whether your current code works when launching through your LMS in a separate window?
Hey Alexandros. We just tried it. Didn't work. Thanks for the suggestion.
Still looking...
This discussion is closed. You can start a new discussion or contact Articulate Support.