개요
현재 페이지가 롱폴링 방식으로 주기적으로 갱신되기 때문에 화면 내 텍스트를 복사하기 쉽지 않은 환경입니다.
따라서, 별도 버튼을 추가하여 복사하는 기능을 javascript로 구현해봤습니다.
코드
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copyToClipboard(str)
{
var textarea = document.createElement('textarea');
textarea.value = str;
document.body.appendChild(textarea);
textarea.select();
textarea.setSelectionRange(0, 9999);
document.execCommand('copy');
document.body.removeChild(textarea);
$.alert('', '복사 완료.');
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copyToClipboard(str) | |
{ | |
var textarea = document.createElement('textarea'); | |
textarea.value = str; | |
document.body.appendChild(textarea); | |
textarea.select(); | |
textarea.setSelectionRange(0, 9999); | |
document.execCommand('copy'); | |
document.body.removeChild(textarea); | |
$.alert('', '복사 완료.'); | |
} |
출처
stackblitz.com/edit/simple-copy-board
반응형
'[DEV] 기록' 카테고리의 다른 글
[SpringBoot] Excel 생성 및 다운로드 (0) | 2021.05.17 |
---|---|
티스토리 블로그 내 gist css 수정하는 방법 (0) | 2021.04.25 |
[SpringBoot] 세션이 만료될 때 세션 값 가져오는 방법 (0) | 2021.04.24 |
[c++] 문자열 내 특정 부분문자열 위치 찾기 (1) | 2021.04.24 |
[크롤링] 경향신문 크롤링 (6) | 2021.04.12 |