HTML5 alternative to flash-based ZeroClipboard for safe copying of data to clipboard?

前端 未结 6 1484
春和景丽
春和景丽 2020-12-02 14:22

With flash on the way out in many environments (iPhone, Android, IE10, etc...), is there any new solution forthcoming in any browsers that will allow a safe copy of informat

6条回答
  •  孤城傲影
    2020-12-02 14:33

    You can look at this blog post for an in-depth discussion of how to work with the clipboard in HTML5. Unfortunately, you still can't portably copy to the clipboard on click. However, for chrome and firefox you can create a browser extension that can give your site permission to access the clipboard, and I believe IE will let you copy to the clipboard, but will prompt the user to grant permission.

    Update:

    According to this: https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand Firefox 41+, Chrome 42+, and IE 9+ support the copy command with execCommand. For firefox and chrome it will only work if triggered by a user action such as a click, and for IE it will give the user a warning dialog asking them for permission to copy to the clipboard.

提交回复
热议问题