Skip to content

Event Overview

The edML player triggers JavaScript events during various processing operations. These events are always "dispatched" from the DOM object in which the player is located. This DOM object can also be easily identified in the DOM tree by the attached edmlplayer class, e.g. using:

var edmlnode = document.querySelector('.edmlplayer');

Using a "JavaScript listener", these events can be monitored and handled accordingly. In the following example, the "listener" is added and an alert is triggered using an anonymous function:

var edmlnode = document.querySelector('.edmlplayer');
edmlnode.addEventListner('edmlevent',function(evt){
    alert("The event has occurred!");
});
The name of the event must be specified for edmlevent. The following events are generally available:

  • edmlevent-changelanguage
  • edmlevent-coursestarted
  • edmlevent-error
  • edmlevent-newpage

Note: The DOM object in which the edML player is running can also be obtained using the getOutput() method of the edML player object.