javascript, jquery
url 주소를 클립보드로 복사하기
디츠
2015. 9. 16. 16:11
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);
}
<button onclick="copy_to_clipboard('Hello Jmnote2');">복사</button>