1. Open the console of your browser (see below)
  2. Enter the listener code (see below)
  3. Test you application and see whether console reports log "event triggered" when you would expect it

How to open the console?

  • In Chrome, press CTRL + SHIFT + J to open the “console” tab of the Developer Tools.
  • In Safari, enter the Preferences menu. In the Advanced part, check "Show Develop menu in menu bar". Then go back to your page, and press CTRL + ALT + I to open the Web Inspector. Then click on "show console".
  • In Firefox, press CTRL + SHIFT + K (COMMAND + SHIFT + K on Mac) to open the Web Console.
  • In Opera, press CTRL + SHIFT  I to open Dragonfly. Then click on "console".

Listener code:

window.addEventListener('custom_event_name', function (e) { console.log("event triggered"); }, false); 

The example above listens for events on element "document". Please update the name of your relevant element.

The example above listens for event with name "custom_event_name". Please update the name of the custom event you test.

You can test whether your listener code works properly by the following test script:

const event = new Event('custom_event_name');

If it works, the browser console should contain the message "event triggered".