Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  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. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement