internet explorer - execCommand('copy') silently fails in IE when the user answers the prompt with 'Don't allow' -
if security level set @ least 'medium' in ie (tested in edge & 11) when execute execcommand('copy') command, browser prompts you, asking if wan allow page manipulate clipboard.
my problem is, if click on 'don't allow', execcommand('copy') still returns true. also, no errors thrown.
how can catch , handle user response?
this older question, i'll chime in since came across issue myself.
what ended doing use fact ie support document.execcommand('paste')
method. said, can paste copied material hidden input , check against content should've been copied.
if user had allowed clipboard manipulated, pasted content , copied content same. otherwise, won't be. this:
var copysuccess, canpaste; inputelementtocopy.select(); copysuccess = document.execcommand('copy'); inputelementtopaste.select(); canpaste = document.execcommand('paste'); if (canpaste) { copysuccess = inputelementtopaste.value === inputelementtocopy.value; // since ie supports paste, // if user allowed clipboard: copysuccess === true // else: copysuccess === false }
Comments
Post a Comment