Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2003
    Atlanta, GA
    Thanked 0 Times in 0 Posts

    Retrieve added events? (debug purposes)

    While debugging a script, I found that I need to try and verify which if any event listeners are added to an event target, and looking at the standard event handler assignment yields undefined. For example:

    var el = document.getElementById('el');
    try {
       el.addEventListener('click', fnRef, false);
    } catch (er) {
       el.attachEvent('onclick', fnRef);
    alert(el.onclick); // alerts undefined
    Is there any way to access the event stack for an event target? I can't tell if my events are being added, because they show no sign of execution; yet I don't know how to verify that they are indeed added.

    Thanks in advance.

  2. #2
    Master Coder
    Join Date
    Feb 2003
    Umeň, Sweden
    Thanked 83 Times in 74 Posts
    There is no accessible list of the event handlers, no. In some areas the DOM event model has holes large enough to get an Airbus through. The event handler has been assigned because no exception has been thrown. To try to see whether they work, trigger the even and let each event handler report to you.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts