Skip to main content
zreichenbachcarr
Inspiring
November 22, 2011
Question

Using the Execute JavaScript Window

  • November 22, 2011
  • 1 reply
  • 9863 views

Curious if there is a simple way to attach javascipt to a Cap 5 project other than opening the standard.js and putting it in there.

I am trying to add 2 functions to a project so they will be accessable by the project at anytime. Is there a way to embed the two functions in the file or do I have to publish and then add.

Thanks for the help.

ZSRC

This topic has been closed for replies.

1 reply

Legend
November 22, 2011

You have a few choices:

1.  In the .htm wrapper containing the .swf using script tags

2.  In a .js file (like the standard.js file)

I typically put my JavaScript functions in the standard.js file.  I alter the standard.js template in the Captivate install directory.  That way, all of my JS functions are available every time I publish.  Then inside of Cp, I can call my functions like:    GoToSlide(5);

Captivate doesn't care whether the JavaScript is in the .htm wrapper, in a .js file, or in the Captivate JavaScript panel.  It all gets pumped to the browser's DOM anyway.  (DOM = Document Object Model).  What DOES matter is the order of operations when getting a reference to the Captivate object.  There's a chance you could reference the Captivate object before it's actually created.  You want to make sure the .htm and .swf are done loading before you perform any action on the Captivate object.  I usually get a reference to the Captivate object on the slide entry action of the first slide of the Cp project:

var objCp = document.Captivate;

That way I know for sure that the Captivate object is loaded and ready.

HTH,

Jim Leichliter

zreichenbachcarr
Inspiring
November 22, 2011

Jim,

Thanks for the quick response. I was using the standard.js

I was really looking to see if I could add all of my functions inline in the Execute javascript script window, but it doesn't seems to liek that option. Or I should be it doesn't appear to be an option.

Thanks again for the feedback. I do like the idea of editing the "master standard.js file" That may accomplish what I need as well.

Legend
December 10, 2011

One thing to note is that Captivate's JavaScript panel will not accept comment tags like:

//This is a JavaScript comment

/*And this is

A Comment That

Spreads between

Line Breaks*/

I like to comment my code but if you do, your JS won't run.