개발/Javascript

[자바스크립트] 클립보드 복사

soohkang 2020. 7. 28. 13:50
728x90

도움받은 블로그

https://velog.io/@godori/js-clipboard-copy

 

JavaScript 클립보드 복사 구현하기

많은 사이트에서 버튼을 클릭하면 정해진 텍스트를 클립보드로 카피할 수 있는 기능을 사용하고 있습니다. copy-gif.gif 클립보드에 데이터를 복사하는 방법은 execCommand API 를 사용하거나 ClipboardAPI

velog.io

 

관련 링크

https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand

 

Document.execCommand()

When an HTML document has been switched to designMode, its document object exposes an execCommand method to run commands that manipulate the current editable region, such as form inputs or contentEditable elements.

developer.mozilla.org

https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API

 

Clipboard API

The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard. Access to the contents of the clipboard is gated behind the Permissions API: The clipb

developer.mozilla.org