SHARE
TWEET

Untitled

a guest Jul 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var timerID = null
  2.  
  3. document.addEventListener('dblclick', function() {
  4.     console.log('double click!');
  5.  
  6.     if (timerID) {
  7.         clearTimeout(timerID);
  8.         timerID = null;
  9.     }
  10.  
  11.     document.onselectstart = function() {
  12.         return false;
  13.     };
  14.  
  15.     if (window.getSelection) {
  16.         if (window.getSelection().empty) {  // Chrome
  17.             window.getSelection().empty();
  18.         } else if (window.getSelection().removeAllRanges) {  // Firefox
  19.             window.getSelection().removeAllRanges();
  20.         }
  21.     } else if (document.selection) {  // IE?
  22.         document.selection.empty();
  23.     }
  24.  
  25.     timerID = setTimeout(function() {
  26.         document.onselectstart = function() {
  27.             return true;
  28.         };
  29.     }, 500);
  30. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top