Skip to main content
Participant
March 3, 2016
Answered

Captivate 7 - Captivate Javascript commands not executing.

  • March 3, 2016
  • 1 reply
  • 370 views

The common javascript command

alert("message")

works just fine.

Captivate specific commands do not and stop the execution of any subsequent javascript.

alert("message1");

var myStr = window.cpAPIInterface.getVariableValue("myVariable");

myStr = myStr.toUpperCase();

window.cpAPIInterface.setVariableValue("myVariable", myStr);

alert("message2");

The first alert executes, the second alert doesn't, and the Captivate variable doesn't get modified to uppercase.

Is more than the standard.js file required for the Captivate commands to function?

This topic has been closed for replies.
Correct answer TLCMediaDesign

The common JS Interface is not available in CP7.

You need to execute different code for HTML5 and swf.

For swf you need to get the Captivate object:

var cpObj = document.getElementById('Captivate')

then use the External Interface:

cpObj.cpEIGetValue('m_VarHandle.' + yourVariable)

HTML5 is :

cp.vm.getVariableValue(yourVariable)

1 reply

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
March 4, 2016

The common JS Interface is not available in CP7.

You need to execute different code for HTML5 and swf.

For swf you need to get the Captivate object:

var cpObj = document.getElementById('Captivate')

then use the External Interface:

cpObj.cpEIGetValue('m_VarHandle.' + yourVariable)

HTML5 is :

cp.vm.getVariableValue(yourVariable)

crg381Author
Participant
March 4, 2016

Many thanks! Worked first attempt.

I've successfully used this form of JavaScript in the past with earlier versions of Captivate. Where can I find a JavaScript reference for Captivate 7? Apparently searching only returns material for Captivate 8 and later, but gives the impression it also applies to Captivate 7.

Again, thanks for ending hours of frustration.