JavaScript System Date - Does not appear on screen
May 08, 2014
I don't know much about JavaScript (I have enrolled in a course that begins next week) so please bear with me and, if you can, translate your replies into "Captain Dummy-Speak" for me. Assume I know nothing, because at this point, it's accurate.
I am trying to pull the system date from the computer to display on another page. I have created a text variable SystemDate and have copy & pasted the following JavaScript
var currentTime = new Date();
var monthArray = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");
var month = currentTime.getMonth();
var theMonth = monthArray[month];
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var dateString= day + " " + theMonth + " " + year;
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
The JavaScript is set to trigger when timeline starts on the slide.
When I publish and view the course (from harddrive) in my browser, the %SystemDate% area of the textbox is blank. All my other variables (user entered) appear on the page correctly.
I am using Update 5: 1401.2415 and viewing the output in IE 11.
Does anyone have any ideas as to why the field is displaying no information?
2 Replies
publish to CD and use exe file or upload to a web server to test javascript
If it doesn't work then look at your javascript
Phil,
Thank you so much. That's exactly what I was missing! Works like a dream when I upload it to the web server instead of trying to view the file in my browser from my hard drive.
This discussion is closed. You can start a new discussion or contact Articulate Support.