What is the best way to determine when Lectora's scripts are complete/page objects are available?

Answers
-
chrystalb21 Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 31 ✶ Headliner ✶Thanks for the suggestion. Our script runs at the top level, and if we were to change it to on OnShow event, it would have to be done on the last object of every page, so that wouldn't be feasible for us. I have successfully used the following code that looks at the Lectora variable bPageLoaded.
var loadInt=setInterval(start,100);
function start(){
if(bPageLoaded){
clearInterval(loadInt);
//Code to run
}
} -
chrystalb21 Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 31 ✶ Headliner ✶
Here is some updated information and actual script from someone at eLearning Brothers:
The easiest way to run your scripts after a page has been loaded in a portable fashion is to have a Lectora Action run On Show of the Project, or a specific chapter, section or page.
That's the best guidance to make your scripting work for Lectora Desktop and Online, for Seamless Play and non-Seamless Play publishing options.
Add the following to a javascript action (preferred), or if updating script, it can be used in the javascript code:
$(window).ready(doAfterLectoraLoad);
Javascript functions:
function doAfterLectoraLoad() {
if(!window.bPageLoaded) {//we want it to match
setTimeout(doAfterLectoraLoad, 50);//wait 50 millisecnds then recheck
return;
}
afterLectoraLoad();
}
function afterLectoraLoad() {
//Enter the code to run after Lectora is loaded
}
-
chrystalb21 Community Member, Lectora® Accessibility Group (LAUG) Member, eLearning Brothers® Partner Posts: 31 ✶ Headliner ✶
Because the Lectora Action is always run after the Lectora page is loaded, there is a correction:
Example if using the Lectora Run Javascript:
Javascript in Lectora: afterLectoraLoad();
Javascript code:
function afterLectoraLoad() {
//Enter the code to run after Lectora is loaded
}
If using in Script only:
Javascript code:
$(window).ready(doAfterLectoraLoad);
function doAfterLectoraLoad() {
if(!window.bPageLoaded) {//we want it to match
setTimeout(doAfterLectoraLoad, 50);//wait 50 millisecnds then recheck
return;
}
afterLectoraLoad();
}
function afterLectoraLoad() {
//Enter the code to run after Lectora is loaded
}
Categories
- 35.9K All Categories
- 109 ✫ Announcements
- 33.1K Lectora®
- 31.1K Lectora Discussions
- 29K Lectora Desktop
- 2K Lectora Online
- 2K Lectora Feature Requests
- 71 Lectora User Groups
- 36 Lectora Accessibility User Group (LAUG)
- 25 ELB Learning Content
- 25 ELB Learning Content Discussions
- 329 CenarioVR®
- 196 CenarioVR Discussions
- 133 CenarioVR Feature Requests
- 42 Rockstar Learning Platform®
- 39 Rockstar Learning Platform Discussions
- 108 CourseMill®
- 108 CourseMill Discussions
- 47 ReviewLink®
- 47 ReviewLink Discussions
- 7 The Training Arcade®
- 7 The Training Arcade Discussions
- 936 All Things eLearning
- 37 eLearning Development
- 546 Learning Management System (LMS) Integration
- 333 Web Accessibility
- 1.2K ♪ The Green Room
- 9 Additional Learning Products