Created
October 3, 2015 19:51
-
-
Save garrettr/ad29d0d32e88a0bd4f43 to your computer and use it in GitHub Desktop.
document.queryCommandSupport('copy') needs to be user-initiated in Chrome, but not in Firefox
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
<!doctype html> | |
<html> | |
<head> | |
<title>Test document.queryCommandSupported</title> | |
</head> | |
<body> | |
<p id="copySupportedNonUserInititated"><code>document.queryCommandSupported('copy')</code> (non user-initiated): <span id="copySupportedNonUserInitiatedResult"></span></p> | |
<p id="copySupportedUserInitiated"><code>document.queryCommandSupported('copy')</code> (user-initiated): <span id="copySupportedUserInitiatedResult"></span></p> | |
<button id="testCopySupportedUserInitiated">Click me to test user-initiated document.queryCommandSupported</button> | |
<script type="text/javascript"> | |
var copySupportedNonUserInitiated = document.queryCommandSupported('copy'); | |
document.querySelector('#copySupportedNonUserInitiatedResult').innerHTML = copySupportedNonUserInitiated; | |
var testButton = document.querySelector('#testCopySupportedUserInitiated'); | |
testButton.addEventListener('click', function () { | |
var copySupportedUserInitiated = document.queryCommandSupported('copy'); | |
document.querySelector('#copySupportedUserInitiatedResult').innerHTML = copySupportedUserInitiated; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment