Running Script after Lectora

chrystalb
chrystalb Community Member Posts: 32
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.

Comments

  • smiller7502
    smiller7502 Community Member Posts: 181
    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.
  • chrystalb
    chrystalb Community Member Posts: 32
    Awesome, thanks, I'll try that:)
  • approg
    approg Community Member Posts: 258 ♪ Opening Act ♪
    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.