Forum Discussion
Can't Get JavaScript To Work
I've reviewed the other articles on this but haven't been able to solve my problem. I added a trigger "Execute JavaScript When the timeline starts on this slide" and in the JavaScript section I copy & pasted some code for a confetti effect I found online. So I don't think the issue is with the code, or the trigger, and I did publish the project but the JavaScript still didn't run. Any thoughts? (I'm using a mac but I don't think that should matter.)
- MathNotermans-9Community Member
Do share both the code and your Storyline for help... like this its just guessing.
Do check your code in the console and/or an external proper code-editor like Brackets or SublimeText. The code-editor in Storyline doesnot give away errors.
Also watch quote-marks. When copying / pasting from the web this often is an issue. You can easily solve that by checking it in a code-editor or in the console. - SC-9c05e08f-32aCommunity Member
Thanks Math - good idea about checking the console. When I published my project, opened the html file, and looked in the console, it said confetti was not defined. Do you know how to fix this? The code can be seen in the trigger in the attached file.
- Jürgen_Schoene_Community Member
you have not included the library "confetti.browser.min.js"
https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js
I have included the library local in the trigger script - not ideal, but it works
if you use the script several times in the course - there are better ways to include the library
https://360.articulate.com/review/content/dd8fc1a2-00ac-47b4-a637-aa632c2a8432/review
- SC-9c05e08f-32aCommunity Member
Ok thanks! I'll take a look and read up on how to include the library when using JavaScript.