Accessing iframe’s function from Storyline slide

Jan 23, 2020

I’ve embedded a website contained in an iframe inside a Storyline slide and I’m trying to call a javascript function from that website. To do this, I’ve added javascript code inside an “Execute JavaScript” trigger. However, I haven’t been successful yet. Here’s the code I’ve tried so far:

 

Attempt 1:

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

iframeElements[0].contentWindow.restartConversation();

Error:

“cannot read property “restartConversation” of undefined.

 

Attempt 2:

$(document).ready (function (){
var iframeElements = document.getElementsByTagName("iframe");

iframeElements[0].contentWindow.restartConversation();

});

Error:

$ is not defined

 

I’ve checked that the iframe object is the correct one and that the function “restartConversation()” exists.

What am I doing wrong? Help!

2 Replies

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