Forum Discussion

JimOwen-707d222's avatar
JimOwen-707d222
Community Member
2 years ago

Javascript not being called

Hi, I am not conversant in JS, but have copy-pasted a script to be executed when timeline starts on a slide. However, it looks as if it is not being called at all. 

The Trigger is "When timeline starts on this slide, Execute Javascript", and here is the JS I am trying to execute:

var player=GetPlayer();

player.SetVar("varRandom", Math.floor((Math.random()*1000)+1););

alert("It is " + player.GetVar("varRandom"););


I publish the course, and run it and nothing happens. I also have a TextBox on this slide which displays varRandom. It is always still the default, of 0.

What am I missing?

(btw I am aware that there are easier ways to get random numbers. This is just dummy code to debug this problem. IRL the code will be different.)