Student name retrieval by JavaScript doesn't work on IE 11 - HTML5 only

Jan 18, 2018

Hi Heroes, 

I am using a JS code to retrieve the student name from the LMS. My code works on Chrome but not on IE11. I tested my scorm packages on Moodle. I am publishing for HTML5 only. I tried HTML5 with Flash fallback and it didn't work on IE 11 but worked on Chrome. Could you please check my code below and let me know if you could suggest any solution? I appreciate your help.

The code

//find out if html5 version is running

var path = window.location.pathname;
var html5 = path.includes("html5");

if (html5 = true) { //if html5 is running run this script
var player = GetPlayer();

function findLMSAPI(win) {
// look in this window
if (win.hasOwnProperty("GetStudentID")) return win;

// all done if no parent
else if (win.parent == win) return null;

// climb up to parent window & look there
else return findLMSAPI(win.parent);
}


var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);

} else { //if html5 isn't running (in other words flash) run this script

var player = GetPlayer();
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);

}

Many thanks,

Amir

 

6 Replies
Nancy Woinoski

Hi, this is the code I use and it works in IE 11 - html 5 only or with flash and it works in chrome.

var player = GetPlayer();
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);
var lmsName = lmsAPI.GetStudentName();
var commaIndex = lmsName.indexOf(',');
player.SetVar("UserName", ((commaIndex == -1) ? lmsName : lmsName.substr(commaIndex + 1).trim() + ' ' + lmsName.substr(0,commaIndex)));

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