Javascript just not working for me

Nov 16, 2015

G'day!

I want to use Javascript to perform some mathematical calculations. Specifically I want a slider to show the exponent of its value and act like a logarithmic scale.

However, my scripts fail the moment I use GetVar or SetVar.

var player = GetPlayer();
document.bgColor = "#009900";
var mynewvalue = 10;
player.SetVar("LogValue",mynewvalue);
document.bgColor = "#990000";

The code above triggers when a slider moves. I'm changing the background colour of the document to help me debug.

When I slide the slider, the background colour of the page turns green so GetPlayer is fine but SetVar isn't.

Because the background colour is changing as expected, I assume the issue must lie with my code.

I can't see anything wrong with my code so I'm hoping somebody with eagle-eyes can spot it for me!

4 Replies
Christie Pollick

Hi, Chris -- Welcome to the community, and I see that Matthew has offered some suggestions for you to consider! I wanted to stop in to note (as we are not able to provide support for JS coding) that you may also want to check out this info sheet on JS Best Practices and keep it handy for your reference. Best of luck with your project! :)

Chris Reynolds

Thanks Christine. I've read that document and appreciate that providing support for Javascript would be a challenge. It's great that the feature is there in the first place!

I think that my issue is due the fact I'm viewing the files locally. Firefox doesn't like the Javascript but IE does. I'm guessing at this stage that Firefox is protecting me against (the risk of) malicious code so next step is to pop it up onto a server and see if the behaviour is remedied.

This discussion is closed. You can start a new discussion or contact Articulate Support.