Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save BiosBoy/c2a21d1e52cb85ce11b6d4e257bc807c to your computer and use it in GitHub Desktop.
Save BiosBoy/c2a21d1e52cb85ce11b6d4e257bc807c to your computer and use it in GitHub Desktop.
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