WebObject and Storyline Variable

Hi!

I have a problem, I need to use a webobject with my project, but my webobject needs some informations. So, I put them in variables in Storyline and now my problem is how I can give them in the query string like this : 

http://mywebobject.com/mysite.php?info1=VariableSL1&info2=VariableSL2 

Do you have any idea? 

Thank you very much! 

30 Replies
Jacqui Yoo
Linus NoName

For future reference for others, you can do to it like this for html5. In the slide where the webobject exists, create a new Javascript that starts at the beginning of the timeline. The script below is my interpretation of how to solve the OP's problem:

// Find and change the src part of the iframe (this will take the first webobject in the storyline, therefore [0]. If you want the second one, use [1], etc..
var iFrameElem = document.getElementsByClassName('item webobject')[0];

var src = "http://mywebobject.com/mysite.php"

var player = GetPlayer();

var var1 = player.GetVar("info1");

var var2 = player.GetVar("info2");

// Add together the finished url with querystrings

var finishSrc = src + "?info1=" + var1 + "&info2=" +  var2;
iFrameElem.setAttribute('src', finishSrc);

Thanks, Linus!

This worked, but I had to change the class from 'item webobject' to 'item webobject unhideable', as the containing div also uses the class 'item webobject'.

I was not initially clear, but the order of the web object [0] for first, [1] for second, etc. is specific to the slide, and not the entire project.

I am using Storyline 2, Update 11.

Matthew Bibby

Something like this should do the trick Christian:

var player = GetPlayer();
if (/html5/.test(window.location.href)) {
player.SetVar("Output","HTML5");
} else {
player.SetVar("Output","Flash");
}

You'll need a text variable in Storyline called Output for this to work.

The JS will simply update that variable with either HTML5 or Flash, depending on which output is being viewed.

John Boulay
Matthew Bibby

Something like this should do the trick Christian:

var player = GetPlayer();
if (/html5/.test(window.location.href)) {
player.SetVar("Output","HTML5");
} else {
player.SetVar("Output","Flash");
}

You'll need a text variable in Storyline called Output for this to work.

The JS will simply update that variable with either HTML5 or Flash, depending on which output is being viewed.

Very helpful html5 test Matthew, love simplified code, thanks!

Matthew Bibby

Glad that it is helpful for you John.

Once caveat with this code... don't include html5 in your project name. This code works by looking at the URL for html5 and if it finds it, it assumes the learner is viewing the HTML5 output.

However, if you have a project called "Introduction to HTML5", then this code will get confused.