Forum Discussion
MarineLancelin
4 months agoCommunity Member
Get variables from iframe in Javascript
Hi!
I created a custom variable "isStorylineCompleted" in Storyline that is set to "true" when the last slide is viewed. And in my parent window, I would like to show a button if the last slide is viewed.
My Storyline is embedded in an iframe and I would like to get the value of this variable "isStorylineCompleted" in the parent view in javascript.
I am a developper but I do not use the Storyline software myself.
Thank you so much for the help :-)
- Jürgen_Schoene_Community Member
if the LMS and the course in the iFrame are in the same domain*, it's easy
javascript trigger in Storyline
const player = GetPlayer();
const completed = player.GetVar("isStorylineCompleted");
if(parent && parent.setCourseState){
parent.setCourseState( completed );
}javascript in the outer html
<script>
function setCourseState( inState ){
alert( "course state: " + inState );
}
</script>* if not use postMessage