How to Add Custom Interaction to Your Training Using JavaScript

At the 2013 Lectora® User Conference, presenter Brad Harmon highlighted the important role of JavaScript in any published Lectora e-Learning course. In his presentation, “Using JavaScript to Add Custom Learning Interactions to your Lectora Course,” Harmon demonstrated different ways to add custom interactions to online training courses using JavaScript.JavaScript is the most widely used client-side scripting language on the web. It’s used for adding functionality to web pages, web form validation or manipulating objects on a page. This makes it a very useful tool in the skill set of any e-Learning developer or instructional designer.Lectora e-Learning content published for the Web, AICC and SCORM relies heavily on JavaScript. In looking at the files within your published Lectora e-Learning course, you will discover several JavaScript (.js) files. These highlight the importance of JavaScript to the published Lectora title.Now let’s take a look at a few ways Harmon says you can add custom interaction to your Lectora e-Learning course by including JavaScript.Include Custom JavaScript into your Title: Add an External HTML Object. Next, insert your script in either the custom HTML field or as an external .txt file.Customize the HTML Field: When using the Custom HTML field, the entire script will reside within the field provided. This works well for short and simple scripts.

Customize an HTML Field in Lectora

Use External Text File: When using the external .txt option, you will create a blank .txt file. In the text file, you will need to add: <script type="text/javascript"> your script </script>. Start and end tags with your script in between.

Insert External Text File in Lectora

Call JavaScript Functions: JavaScript functions can be called by several different methods. Here is one example:

  • Add an Action and set to – Run JavaScript, myFunction();
Call JavaScript Functions in Lectora

For more great resources about adding JavaScript to your Lectora titles be sure to check out:

Tap into other great e-Learning tips by subscribing to the Lectora e-Learning Blog or visit Lectora University!