

There are many cases where you have interactions that require jumping to another slide in the module. The classic case is a “menu” slide with a number of options, where selecting an option transfers the learner to a particular lesson or detail slide. This is also the basis of how adaptive learning is actually implemented.
Captivate provides you a way to jump to a particular slide using advanced actions. Once you point to a particular slide, the advanced action jump will follow that slide even if it is moved or other slides are added before or after. This is a well known capability that has been part of captivate for a long time.
There are some cases where having the ability to perform these kinds of jumping functions in javascript is an advantage.
- It is sometimes easier to develop more complex branching decisions in javascript than directly in advanced actions
- There are cases where one wants to use a named object rather than a slide name to identify which slide to go to
- If slides are deleted, captivate removes the “jump to slide” action and replaces it with a “continue” action.
Jump to slide by slide name
The following shows how to implement jump functions in Javascript. First, we define a Javascript function that gets added to the menu slide, and then each button is set up to call this function with the name of the slide that it wants to have the user jump to.
The javascript function is:
function gotoSlideNamed(aName) { var cpObjectList = Object.getOwnPropertyNames(cp.D); // get all of the captivate-defined objects var findSlideLabels = function ( acc, val ) { // extract objects that have slide names if ( typeof cp.D[val].lb == "undefined" || cp.D[val].lb == "" ) return acc; acc[cp.D[val].lb ] = cp.D[val].from ; // pick up the frame number return acc } var cpSlideObjects = cpObjectList.reduce ( findSlideLabels , {} ) // run the function on all of the captivate objects cpCmndGotoFrameAndResume = cpSlideObjects[aName]; // set the "next frame" variable to the start frame of the object return ; }
gotoSlideNamed("action_1") // action_1 is just a made-up name, you put the name of your desired slide there..
gotoSlideNamed("top_menu")
Jump to slide by name of shape
There are some cases where you’d rather jump to a slide that happens to have an element on it with a specific name. In this case, there is another function we use that works for named elements rather than slide names:
function gotoSlideWithShapeName(aName) { var theSlide = cp.D[aName].apsn; // get parent slide name cpCmndGotoFrameAndResume = cp.D[theSlide].from // set next frame to the start frame number of that slide return }
If you have a shape on the target slide with the id “section_3” you can have a button that simply calls the javascript function:
gotoSlideWithShapeName("section_3")
With these two functions, branching paths can be accomplished in Javascript, which can be an advantage in cases where you have complex branching scenarios.
For more information, contact sdwarwick@elearningocean.com
Steven, like your blog posts, but really want to add a comment (my nickname is Queen of Advanced Actions). The Command ‘Jump to Slide’ works with slide names as well as slide numbers. In every use case I posted on my blog I always recommend never to use slide numbers in any advanced or shared action but always to use slide labels. I am also called ‘labeling freak’. I agree that JS is more powerful, but do not underestimate advanced/shared actions!