Created
July 8, 2019 13:50
-
-
Save BiosBoy/c2a21d1e52cb85ce11b6d4e257bc807c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timerID = null | |
document.addEventListener('dblclick', function() { | |
console.log('double click!'); | |
if (timerID) { | |
clearTimeout(timerID); | |
timerID = null; | |
} | |
document.onselectstart = function() { | |
return false; | |
}; | |
if (window.getSelection) { | |
if (window.getSelection().empty) { // Chrome | |
window.getSelection().empty(); | |
} else if (window.getSelection().removeAllRanges) { // Firefox | |
window.getSelection().removeAllRanges(); | |
} | |
} else if (document.selection) { // IE? | |
document.selection.empty(); | |
} | |
timerID = setTimeout(function() { | |
document.onselectstart = function() { | |
return true; | |
}; | |
}, 500); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment