Many Storyline and Captivate courses use small "Execute JavaScript" actions, for example to set a variable or open a page. Xogogy keeps them when you import a .story, .cptx or .cpt file or a published Storyline package, and the published player runs them in the learner's browser. Common Storyline GetPlayer().GetVar and SetVar calls and Captivate variable calls keep working. Scripts in a published Captivate package are not kept as scripts; the import report lists them.
To write a new script of your own, see How do I add my own JavaScript to a course?.
See a course's scripts
- #
Select the object or slide that has the interaction.
- #
On the Inspector's Interactions tab, choose Edit on the interaction's card. Its card summary reads run JavaScript: followed by the start of the code.
- #
The Execute JavaScript action shows its code as text, with line numbers. You can read and change it there.
Edit a script in the large editor
- #
Choose Expand beside the code, or press Ctrl+Shift+Enter in it. The code opens in a large editor with line numbers, Tab indentation and the Supported player API beside it.
- #
To refer to an object, choose Insert object reference (Ctrl+Shift+O). Pick an object from this slide, the slide master or the layouts. Xogogy inserts
course.object('Name')at the caret. - #
An object needs a script name to be referred to. Pick an unnamed object and Xogogy suggests a name; choose Name and insert to set it and insert the reference in one step.
- #
Choose Insert snippet (Ctrl+Shift+K) for a starting point: All images on this slide, When clicked, Show or hide an object, Read a variable or Set a variable. Type over the highlighted
…to fill it in. - #
Choose Save to save the interaction and keep editing, or Done (or Escape) to return to the interaction with your changes.
A note under the code names any line that refers to an object this slide does not have.
Give an object a script name
Scripts reach objects through the course script API, which is in preview: course.object('HeroImage').hide(), for example.
- #
Select the object and open the Advanced section of the Inspector's Design tab.
- #
Type a Script name, such as
HeroImage. Names start with a letter and use letters, digits and underscores, and each name is used once per slide. If a name is not allowed, the field suggests one that is.
A script name stays the same when you rename, move or republish the object. A copy of an object starts without one.
Hand the scripting to your own assistant
Choose File › Export script kit… and pick a folder outside the project. Xogogy writes course-studio.d.ts (this course's slides, script names, states and variables), a README.md and a SKILL.md, ready for your own coding assistant. When you publish, Xogogy warns about any course.object('…') name that no slide has.
Saving a script never runs it. Scripts are only ever run by the player.
Run scripts in Preview, or switch them off
- #
Choose Preview at the right of the ribbon tab row. Course scripts run inside an isolated frame that cannot reach the app, your files or your settings.
- #
Watch the Interaction log in the side panel. An error in a script shows as a Script error line with the message, for example Script error: No object with the script name '…' on this slide. An error inside a click handler that a script set up shows as Script error in a click handler.
- #
To play without scripts, clear Run course scripts in the Preview toolbar.
- #
To see scripts run exactly as a published course would, use Open in browser.
Tip: If Preview cannot set up the isolated frame on your computer, it keeps scripts off and shows a note saying why. The rest of the course still plays.
A script written for one vendor's player can rely on parts of that player that Xogogy does not have. Always try a scripted slide in Preview or in the browser before you publish.
Still stuck?
Write to support@xogogy.com. A person at GForce Learning reads every message. Include the app version from Help › About Xogogy.