document.execCommand for cut, copy and paste no longer throws

Published: | Categories: DOM


Firefox now allows Web pages to modify the content of clipboard programmatically in user-generated event handlers, so click-to-copy actions, for instance, no longer require an alternative solution like Flash Player. See a relevant thread on the dev-platform list and the Mozilla Hacks blog for details.

This change has updated the implementation of document.execCommand and document.queryCommandEnabled, and those methods no longer throw for the cut and copy commands, instead return true in user-generated event handlers or false in other cases. The paste command still won’t work for security reasons, and those methods will return false. The document.queryCommandSupported method now returns a correct value, instead of always returning true.