프로그래밍
[JAVASCRIPT] 클립보드에 복사하기
ReturnToHome
2016. 12. 24. 21:25
반응형
<script type="text/javaScript">
function is_ie() {
if(navigator.userAgent.toLowerCase().indexOf("chrome") != -1) return false;
if(navigator.userAgent.toLowerCase().indexOf("msie") != -1) return true;
if(navigator.userAgent.toLowerCase().indexOf("windows nt") != -1) return true;
return false;
}
function copy_to_clipboard(str) {
if( is_ie() ) {
window.clipboardData.setData("Text", str);
alert("복사되었습니다.");
return;
}
prompt("Ctrl+C를 눌러 복사하세요.", str);
}
</script>
IE 에서 정상 작동
그 외 브라우저에서는 input 과 함께 안내메시지 노출
반응형