At the end of a Storyline module I'm making, I wanted to create an easily printable page that contained all the freetext field entries the learner had made during the course. I tried doing the basic old 'window.print()' - but since Storyline on desktop runs through flash, the print function was being a bit weird.... Continue Reading →
Get learner name from LMS with JavaScript, for Captivate and Storyline
Getting the learner name from the LMS is a nice wee trick to personalise a course (used sparingly!) Using whatever API (in this instance I was using Pipwerks SCORM 1.2 demo shell), var learnerName = get('cmi.core.student_name'); The SCORM standard stores the name as LastName, FirstName MiddleInitial, so the name comes out as 'Blair, Lawrence' for... Continue Reading →
print out xml data that is loaded in javascript / AJAX
Paranoid the reason nothing is coming out is that nothing is coming in? This is a nice and easy alert option to print out your XML doc as an alert, so you know the data's there. If nothing's working - it's some other reason! $.ajax({ type: "GET", url: "courses.xml", dataType: "xml", success: function (data) {... Continue Reading →
Get country from IP address with JavaScript
This uses the telize site to get a geolocation of an IP address. It's not 100% accurate but fine for country-level location, which is all I wanted. <script type="application/javascript"> function getgeoip(json){ //document.write("Geolocation information for IP address : ", json.ip); //document.write("Country : ", json.country); //document.write("Latitude : ", json.latitude); //document.write("Longitude : ", json.longitude); //document.write("Country: " + json.country);... Continue Reading →
Set a SCORM completion in Storyline using javascript
Run this as a 'run JavaScript' in Storyline and you're done-burgers. Storyline 360 (20.03.2018) function findLMSAPI(win) { if (win.hasOwnProperty("GetStudentID")) return win; else if (win.parent == win) return null; else return findLMSAPI(win.parent); } var lmsAPI = findLMSAPI(this); //set score; the first number is the score lmsAPI.SetScore(100, 100, 0); //set status; possible values: "completed","incomplete", "failed", "passed" lmsAPI.SetReachedEnd();... Continue Reading →
Javascript – re-focus on parent window after closing child
Great for CP simulations. As easy as below (run from the js-opened child window/simulation) window.opener.focus(); window.close();
if else questionmark operators
A neat wee time saving way to write an if () {} else {} statement in flash or javascript: var a = true; var b = false; var c; if(a==b?c = true: c = false); trace(c); The statements between the ? and the : are if the if evaluated to true, and after the :... Continue Reading →
Call AS3 functions from javascript and vice versa
To communicate between JavaScript and Actionscript it isn't so hard. FLASH: import flash.external.ExternalInterface; ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript); function getTextFromJavaScript(str):void { trace(str); } JAVASCRIPT: var currentPage="Home"; function setCurrentPage(newPage) { currentPage = newPage; SendDataToFlashMovie(newPage); } So then on the page, this code is run when an item is clicked (javascript function sending to flash) <a href="javascript:void(0);" onClick="setCurrentPage('Home')">Home</a> This javascript... Continue Reading →
Getting around Chrome Javascript error: Chrome Unsafe JavaScript attempt to access frame with URL
In this instance, I had a parent window which launched a bunch of child windows. These child windows needed to run a function on the parent window when a particular function was called. Since the event dispatcher isn't widely working with IE just yet it seems, that wasn't a real option, so I went oldschool... Continue Reading →
Write to local drive with javascript – hta
This will create a text file 'text.txt' in the folder where test.hta is residing. Could use to create xml and config files with javascript for courses to manipulate later. <html> <head> <script language="javascript"> function WriteToFile() { try { var fso, s; fso = new ActiveXObject("Scripting.FileSystemObject"); /* s = fso.OpenTextFile("C:\\test.txt" , 8, 1, -2); */ s... Continue Reading →
Resize html embed area when Flash stage size changes
I've been building an app where the size of the flash area is going to change beyond the bounds of the browser window at certain points - but I do not want to use flash scrollbars, as you're already in a browser and as a user I much prefer the browsers scrollbar over dinky wee... Continue Reading →