Answers for "javascript add event listener list"

1

js add event listener

function eventHandler(event) {
  if (event.type == 'fullscreenchange') {
    /* gestire un interruttore a schermo intero */
  } else /* fullscreenerror */ {
    /* gestire un errore di commutazione a schermo intero */
  }
}
Posted by: Guest on January-08-2021
-1

list listener on a page js

function listAllEventListeners() {
  const allElements = Array.prototype.slice.call(document.querySelectorAll('*'));
  allElements.push(document);
  allElements.push(window);

  const types = [];

  for (let ev in window) {
    if (/^on/.test(ev)) types[types.length] = ev;
  }

  let elements = [];
  for (let i = 0; i < allElements.length; i++) {
    const currentElement = allElements[i];
    for (let j = 0; j < types.length; j++) {
      if (typeof currentElement[types[j]] === 'function') {
        elements.push({
          "node": currentElement,
          "type": types[j],
          "func": currentElement[types[j]].toString(),
        });
      }
    }
  }

  return elements.sort(function(a,b) {
    return a.type.localeCompare(b.type);
  });
}
Posted by: Guest on October-29-2020

Code answers related to "javascript add event listener list"

Code answers related to "Javascript"

Browse Popular Code Answers by Language