Set Variable for Storyline variable from Web Object

Hi Experts,

I know, there would be more experts here who can help me in this problem, Source and Published files are attached for the resolution.

Problem: I have used an images slider of HTML5 and used as Web Object. Then i want to Jump to the next slide if i click on the First image. If i click on the second image, i want to jump on the 2nd slide and so on. So, one method is from variable value, but, how we can pass the variable value from HTML5 Web object to Storyline? It is not passing i have tried many time.

Please help and explain the resolution.

I will really appreciate.

Regards,

Ankit

20 Replies
Tracy Livingston

Hello Crystal. All I really need to be able to do is write my own HTML page, embed as a web objects, and display the answers users enter in data fields as SL variables. The problem is the web object can't seem to access the GetPlayer() to find the variables even when I parent out from the web object iFrame. It all works fine in SL so it's an issue with the iFrame/web object accessing the player variables. I'm going to try and write an external js file and src in both my web object html file and inside the story_html5.html file.

Thanks,

Ashley Terwilliger

Hi Tracy,

You lost me at writing your own HTML page... 🙃

It sounds a bit outside the scope of what staff can help with, but that's why it's amazing that we have such a vibrant community of E-Learning experts to weigh in! 

*Anyone available to help Tracy with some custom Javascript and creating an HTML page to link with Storyline?

Tracy Livingston

Thanks Russell, 

Can you tell me what version of StoryLine was used here? I'm having the same issue in 360 where the web object is apparently not able to access the player via parent.GetPlayer(). What I really need is the ability to pass the StoryLine variables to my HTML doc but obviously, if I can't get to the player than I can't pull, or push values either way :) I'm hoping you created this in 360 and I'm missing something silly.

Tracy Livingston

Using Russell's example here that works fine until I replace the web object with new local path and build in 360 (no other edits). I've haven't been able to share vairables between my web object and SL, either way. It's making me crazy :\

<body>

Webpage Variable: <input type="text" name="Answer" id="Answer">
<br><br>
<input type="submit" value="Submit to Storyline" onclick="sendtostoryline();">

<script language="javascript" type="text/javascript">
function sendtostoryline() {
var sAnswer = document.getElementById('Answer').value
var player = parent.GetPlayer();
player.SetVar("Answer",sAnswer);
}
</script>

</body>

melissa flores

Non-coder desperately seeking help...  Don't know WHERE/WHAT code to input into HTML file to pull variables from storyline.  First, big thanks to all for posted solutions that have gotten me this far! 

.story is set up as a quiz that prompts learner for Name (TextEntryName), Job Title (TextEntryJob) and Date (TextEntryDate).   I have a 3-page Word document that I saved as Print.html and  embedded it on my Results page as a Web Object.  I need to add code to the HTML file to pull in Name, Job Title and Date into their specified locations.

The quiz answers get assigned to the following variables:  varName, varJob and varDate.

I have placeholders in my HTML file:  +LearnerName+, +LearnerJob+ and +LearnerDate+ to receive the Storyline variables:  

And just FYI, my HTML file has added code to print on load:  onload="window.print();".  I set it up as a quiz bcuz I also need to push the answers to LMS.

Per other posts, I came up with the following but don't know where to add it in the html file and how to correctly code my placeholders:

<script>
var player=top.window.opener.GetPlayer();
var LearnerName=player.GetVar("varName");
var LearnerJob=player.GetVar("varJob");
var LearnerDate=player.GetVar("varDate");
document.write("<P><H2>Variable Name: " + LearnerName + "Variable Job: " + LearnerJob + "Variable Date: " + LearnerDate +"</P");
</script>

I've done my best but cannot figure out WHAT/WHERE to add code in the HTML file.  I added a 'redacted' copy of my Print.html file for your to view.

I'm exhausted and crawling to the finish line.  Can anyone PLEASE assist?  Many thanks!