사용자가 텍스트 영역에 클릭 할 때 클립 보드에 텍스트 영역의 내용을 복사하는 순수 자바 스크립트 솔루션 :
<script>
function copySelectionText(){
var copysuccess // var to check whether execCommand successfully executed
try{
copysuccess = document.execCommand("copy") // run command to copy selected text to clipboard
} catch(e){
copysuccess = false
}
return copysuccess
}
function copyfieldvalue(e, id){
var field = document.getElementById(id)
field.select()
var copysuccess = copySelectionText()
}
var bio = document.getElementById('mybio')
bio.addEventListener('mouseup', function(e){
copyfieldvalue(e, 'mybio')
var copysuccess = copySelectionText() // copy user selected text to clipboard
}, false)
</script>
참고 : 클립 보드에 텍스트 영역 내용의 일부만을 복사하려면 , 자습서 Reading and copying selected text to clipboard using JavaScript에 그것에 대한 자세한 정보가 있습니다.
중복 : http://stackoverflow.com/questions/127040/copy-put-text-on-the-clipboard-with-firefox-safari-and-chrome 및 http://stackoverflow.com/questions/ 2072026/copy-to-clipboard-do-on-firefox – RoToRa
이 질문에 대해 제공되거나 받아 들여지는 해결책은 작동하지 않습니다. 그래서 나는 더 나은 해결책을 얻기 위해 그것을 다시 올리려고 생각했다. –