Saturday, November 18, 2017

Javascript to disable double-clicking on a webpage

Use a capture phase event listener on the document:
document.addEventListener(
 'dblclick', function(event) {
  alert("Double-click disabled!");
  event.preventDefault();
  event.stopPropagation();
 },
 true//capturing phase!!
);

8 comments: