Created
April 21, 2015 05:29
-
-
Save hallvors/59a90f2e3816cb57f044 to your computer and use it in GitHub Desktop.
Exploring queryCommandEnabled() vs onbefore* events
This file contains 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
<pre></pre> | |
<script> | |
var pre = document.getElementsByTagName('pre')[0]; | |
document.onbeforepaste = document.onbeforecopy = document.onbeforecut = function (e) { | |
pre.appendChild(document.createTextNode(e.type)); | |
} | |
for(var cmd in {'copy':1, 'cut':1, 'paste':1}){ | |
pre.appendChild(document.createTextNode('\n\n' + cmd.toUpperCase() + '\n')); | |
pre.appendChild(document.createTextNode('queryCommandSupported(): ' + document.queryCommandSupported(cmd) + '\n')); | |
try{ | |
pre.appendChild(document.createTextNode('queryCommandEnabled(): ' + document.queryCommandEnabled(cmd) + '\n')); | |
}catch(e){ | |
pre.appendChild(document.createTextNode('queryCommandEnabled throws: '+e)) | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment