Call function in web object from Storyline

Can someone assist with the syntax to call a function in a web object hosted in Storyline?

Within the web object I have a script that is called by a button: onclick="controls.reset();"

This works fine, but I want to call that function from a Storyline button by running JavaScript.

The issue I have is working out how to address the web object / iframe that the script resides in.

I have tried different variations of this type of code to no avail:

var x = document.getElementsByClassName("webobject");


Can anyone point me to a solution?




10 Replies
Brian Dennis

I'm betting for starters you are blocked by cross script domain issues so the course and web object are effectively running from two different domains. Modern browsers block these types of calls over security concerns.

Second, the course does not exist the DOM as you might expect. I would suggest you walk the DOM and see what markup Storyline generated; it might surprise you.

Knut Jackowski

Hello Mark!

Your tries to access the content of the web object are very close. Since it is an iframe, you can select it like so:

var iframeElements = document.getElementsByTagName("iframe");

And then you can call functions from that:


From your code, I suppose, that you create an object (called controls) in the global scope of that document, that has the method "reset()". If that is the case,


will do the trick of executing this function.

If you have already tried this, maybe the problem is not how to call the function, but the function itself is doing something that does not work from inside an iframe.