JavaScript for Instructional Designers

Add custom interactivity without becoming a developer

Welcome! In this 30-minute course, you'll learn practical JavaScript skills specifically designed for instructional designers working with Articulate Storyline.

What you'll build:

  • Custom interactive components
  • Advanced animations with GSAP
  • Accessible code patterns
  • Ready-to-use code templates

Prerequisites: Basic understanding of Storyline and familiarity with HTML/CSS (a refresher will be provided).

Understanding Storyline's JavaScript Window

When you add JavaScript to Storyline, you're working within the Storyline Player Window. This is the runtime environment where your code executes.

Key Global Object: GetPlayer()

This returns the Storyline player instance, giving you access to variables, triggers, and the slide environment.

// Access the Storyline player var player = GetPlayer(); // Get a variable value var myVar = player.GetVar("myVariable"); // Set a variable value player.SetVar("myVariable", newValue);

When does code execute?

  • On Load: When the slide first loads
  • On Click: When a user clicks a button or shape
  • On Change: When a variable or state changes

Your First Custom Interaction

Let's build something immediately visible. Here's a simple click counter with visual feedback:

0

Click the button below

var clickCount = 0; function incrementCounter() { clickCount++; document.getElementById('counterDisplay').textContent = clickCount; // Optional: Set this to a Storyline variable GetPlayer().SetVar("ClickCount", clickCount); } function resetCounter() { clickCount = 0; document.getElementById('counterDisplay').textContent = clickCount; }

What's happening: Each click increments a variable and updates the display instantly. This same pattern works for scoring, progress tracking, and conditional logic.

Storyline Variables via JavaScript

Variables are the bridge between your JavaScript and Storyline's logic. Create variables in Storyline, then control them with code.

Three Essential Methods:

GetPlayer().GetVar(name) β€” Retrieve a variable value

GetPlayer().SetVar(name, value) β€” Set a variable value

GetPlayer().GetVar(name) β€” Check before using

// Scenario: Track user engagement level var engagementScore = GetPlayer().GetVar("UserEngagement"); if (engagementScore === null) { GetPlayer().SetVar("UserEngagement", 0); } // Increment on interaction var currentScore = GetPlayer().GetVar("UserEngagement"); GetPlayer().SetVar("UserEngagement", currentScore + 10);

Knowledge Check: Variables

Question: What does GetPlayer().GetVar("Score") do?

Debugging: Your Secret Weapon

Every browser has built-in developer tools. Learning to use them will save you hours of frustration.

Open Developer Tools:

  • Windows/Linux: Press F12
  • Mac: Press Cmd + Option + I

Using console.log(): The most important debugging tool

var player = GetPlayer(); var myVariable = player.GetVar("CourseProgress"); console.log("Player object:", player); console.log("Course Progress:", myVariable); // Log with labels for clarity console.log("Starting interaction..."); console.log("User Score:", player.GetVar("Score"));

Pro Tips:

  • Add console.log at the start of functions to confirm they run
  • Log variable values before using them
  • Watch for null or undefined values

Building Reusable Components: Accordion

Accordions are a perfect first reusable component. They're common, accessible-friendly, and demonstrate core JavaScript patterns.

What is JavaScript?

JavaScript is a programming language that runs in browsers, allowing you to create interactive web experiences. In the context of e-learning, it enables dynamic content manipulation and user interactions.

How do I add code to Storyline?

Insert a web object or shape/button, then add an trigger with "Execute JavaScript" action. Paste your code in the dialog. The code runs when the trigger fires (on load, on click, etc.).

Is there a learning curve?

Yes, but you don't need to be a professional developer. Focus on patterns and examples. This course provides templates you can customize without starting from scratch.

function toggleAccordion(header) { const content = header.nextElementSibling; const isOpen = content.classList.contains('open'); // Close all accordions document.querySelectorAll('.accordion-content').forEach(el => { el.classList.remove('open'); el.previousElementSibling.classList.remove('open'); }); // Open clicked accordion if it wasn't open if (!isOpen) { content.classList.add('open'); header.classList.add('open'); } }

Smooth Animations with GSAP

GSAP (GreenSock Animation Platform) is the industry standard for animations. It's lightweight, performant, and intuitive.

Basic GSAP Syntax:

// Animate an element over 1 second gsap.to(".element", { duration: 1, opacity: 1, y: -20, rotation: 360, ease: "power2.out" }); // Stagger animations for multiple elements gsap.to(".card", { duration: 0.6, y: 0, opacity: 1, stagger: 0.1 // 0.1 second delay between each element });

Common Animation Properties:

  • opacity β€” Fade in/out (0 to 1)
  • y β€” Move up/down (pixels)
  • x β€” Move left/right (pixels)
  • scale β€” Grow/shrink (0.5 to 1.5, etc.)
  • rotation β€” Spin (degrees)

Easing Functions: Control animation feel. Common ones: power1.out, power2.out, back.out, bounce.out

Accessibility When Adding Code

Your interactive components must work for everyone. This isn't optionalβ€”it's professional responsibility.

Keyboard Navigation: Users should navigate using Tab and Enter.

// Make custom components keyboard accessible element.addEventListener('keydown', function(e) { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); handleClick(); } });

ARIA Labels: Help screen readers understand your components.

// Good: Accordion with ARIA <button aria-expanded="false" aria-controls="content-1"> Accordion Item </button> <div id="content-1" role="region"> Content here </div>

Testing: Use keyboard-only navigation. Try a screen reader (NVDA is free).

  • olor contrast: Text must be readable for people with vision impairments
  • Focus indicators: Users must see which element has focus
  • Animation controls: Provide pause options for animated content

Hands-On: Build Your Accordion

Now it's your turn. Below is a template accordion. Click "Customize" to modify the content and styling.

Learning Objective 1

By the end of this module, you'll understand how to integrate JavaScript with Storyline variables.

Learning Objective 2

You'll be able to build reusable, accessible components using modern JavaScript patterns.

Challenge: Try adding a third accordion item yourself. Copy the structure, change the text, and test it.

Reflection: What part of building this accordion was clearest to you?

Real-World Integration: Step by Step

Here's exactly how to use these components in your actual Storyline projects:

  1. Create a web object in Storyline (Insert β†’ Web Object)
  2. Choose "Use an external URL or embed HTML"
  3. Paste the component HTML/CSS/JS into the editor
  4. Customize colors/text to match your course brand
  5. Test in preview (F5 in Storyline)
  6. Connect to Storyline variables using GetPlayer().SetVar()
  7. Publish and test in your LMS (SCORM, xAPI, etc.)

Pro Tip: Create a "Components Library" file in Storyline. Save each component as a master slide. Then duplicate it for new courses. This saves time and ensures consistency.

Your Template Library

You now have working code for all these patterns. Click any card to view the full template code:

01. Interactive Counter

Track clicks, submissions, or any user action. Great for gamification.

02. Custom Accordion

Organize content hierarchically. Saves space, improves navigation.

03. Animated Components

Use GSAP for entrance animations, transitions, and micro-interactions.

04. Accessible Patterns

ARIA labels, keyboard navigation, focus management templates.

Click a card above to view its full code, then copy it into Storyline.

Next Steps & Resources

Continue Learning:

Community & Support:

  • Join ID-focused Discord communities
  • Share your components with other IDs
  • Attend webinars on e-learning technology

Challenge for Next Week: Take one component from this course and adapt it for a real project. Share screenshots or code snippets in your learning community!

πŸŽ“

Course Complete!

Congratulations! You've completed JavaScript for Instructional Designers

Certificate of Completion

Learner

Issued:

You can now:

  • βœ“ Write custom JavaScript for Storyline
  • βœ“ Build reusable, accessible components
  • βœ“ Create smooth animations with GSAP
  • βœ“ Debug and troubleshoot code effectively
  • βœ“ Integrate code into production courses