Accessing iframe’s function from Storyline slide

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