Running Script after Lectora

Is there anything that indicates that Lectora scripts have finished executing? I need to run some javascript after, but am having varying results on the LMS, so using a timeout isn't a great solution.

Discussion (3)

Awesome, thanks, I'll try that:)

Try this:

document.addEventListener("DOMContentLoaded", function(event) { 

//your JavaScript here

}

That ensures that the content of the document object model is fully loaded before your code executes.

While Stan's method may work it depends on how you are loading your script(s) and whether you are publishing for Lectora 17 seamless or not. If you are using Lectora 17 then you probably should be using

var doc = getDisplayDocument();

doc.addEventListener("DOMContentLoaded", function(event) {

 //your JavaScript here

}

instead.

Discussions have been disabled for this post