Skip to main content
Inspiring
September 14, 2017
Answered

Controlling captivate project that's inside a iFrame

  • September 14, 2017
  • 2 replies
  • 504 views

I haven't seen anyone post about this yet,

I have a captivate html export that's going to be placed inside a iframe on another html page.

ex.

Parent html > iframe (captivate course)

The idea is, to be able to start the course and jump to specific slides from buttons on the parent page.

So the buttons needs to be able to communicate to the captivate project.

I haven't been able to figure it out how to do this.

I think it's the captivate functions below that are throwing me off on how to get the parent to communicate withe iframe.

.cpAPIInterface.getVariableValue()

.cpAPIInterface.setVariableValue()

Has anyone else been able to do this, I feel like i'm missing a step or not settings something up right.

Nothing I've tried haven't been able to reach the functions or variables in the course and they keep coming back as not defined.

var iframe= $("#eguide").contentWindow;

$("#btn1").click(function() {

iframe.cpAPIInterface.getVariableValue("cpInfoCurrentSlide");

alert(cpInfoCurrentSlide);

});

This topic has been closed for replies.
Correct answer darckraven

I finally figured it out. I was very close to it.

The [0] to identify what iframe to use was what was needed to make it work.

var iframe= $("iframe");

$("#ch1").click(function() {

iframe[0].contentWindow.cpAPIInterface.setVariableValue("cpCmndGotoSlide", "1");

});

2 replies

darckravenAuthorCorrect answer
Inspiring
September 15, 2017

I finally figured it out. I was very close to it.

The [0] to identify what iframe to use was what was needed to make it work.

var iframe= $("iframe");

$("#ch1").click(function() {

iframe[0].contentWindow.cpAPIInterface.setVariableValue("cpCmndGotoSlide", "1");

});

Legend
September 15, 2017

It may be a scope issue.  Try defining iframe inside of your click function.  If you'd like to publish your project, I'd be happy to take a look.

Jim Leichliter