Assign Dynamic URL to Web Object: SL 3

Apr 23, 2019

Hi group

Like many before me, I have the need to assign a dynamic URL (incorporating Storyline variables) to a Web Object in Storyline 3.

I've spent a frustrating day trying the approaches listed in the forums, most from several years ago.

The one that I had most joy with was a javascript approach (as all the better suggestions were) that looked something like:

var iFrameElem = document.getElementsByClassName('item webobject unhideable')[0];
var src = 'https://www.mybaseurl.com';
var player = GetPlayer();
var var1 = player.GetVar('Param1');
var var2 = player.GetVar('Param2');
var finishSrc = src + '?info1=' + var1 + '&info2=' + var2;
iFrameElem.setAttribute('src', finishSrc);

This almost worked for me in Storyline 2, but the same javascript copied into a Storyline 3 project didn't even come close. I don't think the getElementsByClassname even returned anything; interrogating the returned value looked like it was 'undefined'.

Because the other threads in the forums are so old, and seemingly because something may have changed in Storyline 3, I thought I'd start again by seeing if anyone has an answer for this query in respect of HTML5 and (less importantly) Flash output in Storyline 3.

Thanks for anything that you think will work in Storyline 3 and bringing a bit of currency to this problem.

2 Replies
Paulo B

Digging through the DOM a bit I think I've found a solution that works for me.

It looks like line 1 of the sample javascript doesn't work in SL3 (but it did in SL2):

var iFrameElem = document.getElementsByClassName('item webobject unhideable')[0];

I changed this line to look directly look for the iframe item rather than looking for something with the nominated classes and everything magically worked. I.e. change the line above to:

var iFrameElem = document.getElementsByTagName('iframe')[0];

Initial tests seem to work in IE and Chrome, both with Flash and HTML5 outputs.

I'd be interested to know if anyone has had a similar experience in SL3 or success in SL3 using this or another method.

This discussion is closed. You can start a new discussion or contact Articulate Support.