Using execCommand (Javascript) to copy hidden text to clipboard
问题 I\'m trying to copy to clipboard without using Flash, I plan to fall back onto Flash with the use of ZeroClipboard if the browser is incompatible with the javascript approach. I have an onClick listener for the button which looks like: $(buttonWhereActionWillBeTriggered).click(function(){ var copyDiv = document.getElementById(inputContainingTextToBeCopied); copyDiv.focus(); document.execCommand(\'SelectAll\'); document.execCommand(\"Copy\", false, null); } and an input field as follows: