Forum Discussion
HI @Sasikumar Murugan
I am not familiar with Saba Cloud and their LMS - But it may be that you need to add extra code to find the lmsAPI object.
When working with different LMS platforms, the way you access the LMS API may vary. Sometimes, the API object is directly available in the current window. This is more likely when the content is launched in a new window or tab...
...If the content is embedded in an iframe, the LMS API might be available in the parent window (as you are assuming).... if there are several levels of embedding of iFrames you might need to go to the 'top' of that hierarchy to find the LMS API...
...If the content is nested within multiple frames or iframes, the API might best be found by recursively checking each parent window up to a certain depth. Something like this:
function getAPI() {
var theAPI = null;
if (window.parent && window.parent != window) {
theAPI = findAPI(window.parent);
}
if (!theAPI && window.opener) {
theAPI = findAPI(window.opener);
}
return theAPI;
}
function findAPI(win) {
var theAPI = null;
var maxTries = 7; // Maximum depth to search for the API
while ((win.API == null) && (win.parent != null) && (win.parent != win) && (maxTries > 0)) {
maxTries--;
win = win.parent;
}
if (win.API != null) {
theAPI = win.API;
}
return theAPI;
}
var lmsAPI = getAPI(); // This will attempt to locate the LMS API
Hope this helps - please mark as 'helpful' if it does :)
- SasikumarMuruga2 months agoCommunity Member
Thank You Mark! I tried this and still its not providing the results and I did put an alert and I am able to get the Object from lmsAPI call but when I try that var name = lmsAPI.GetStudentName() is not giving any results.