Forum Discussion
JAVAscript does not work in LMS Moodle
What’s happening probably isn’t GSAP — it’s more likely the SCORM runtime environment.
When you publish to Moodle, your Storyline content runs inside a SCORM iframe. Storyline dynamically injects the slide DOM at runtime, so code like:
document.querySelectorAll("[data-acc-text='target']");
may execute:
- before the slide objects exist
- or against the wrong DOM scope
- or before layers have finished rendering
In Preview and Review 360 everything loads faster and flatter, so you don’t see the issue.
In Moodle, the slide content is injected into the #slide-window container inside the SCORM frame — so querying document immediately on timeline start can return an empty NodeList.
What to Try
Delay execution slightly:
setTimeout(function() { // your code here }, 500);
Scope your selector to the slide window instead of the whole document:
var slideWindow = document.querySelector("#slide-window"); var targets = slideWindow ? slideWindow.querySelectorAll("[data-acc-text='target']") : [];
Open Moodle → F12 → Console
Add:
console.log(targets.length);
If it logs 0, your selector is running before the objects exist.
Even Better
Accessibility attributes (data-acc-text) can be fragile across LMS publishing.
If possible, give the objects unique names and select by ID or custom class instead — that’s more reliable in SCORM environments.