Forum Discussion

JohnBowyer-Smyt's avatar
JohnBowyer-Smyt
Community Member
3 years ago

Adding JS event listeners using Javascript trigger

I have tried several times to add Javascript event listeners using the Javascript trigger in Storyline but they never seem to work. Eg.

var video = document.querySelector("video");

video.addEventListener("ended", function() {
  alert("ended");
});

Has anyone had luck with this?

  • If the video is in SL, there is a built-in  "when media ends" trigger. If it is just linked media, I'm not sure you can find its end.

    • JohnBowyer-Smyt's avatar
      JohnBowyer-Smyt
      Community Member

      No, the video is not in Storyline. And my question is more of a general question about applying eventlisterners