더 나은 프로그래머가 되자

클립보드 복사 기능 exeCommand() 본문

언어/js

클립보드 복사 기능 exeCommand()

greathuman 2020. 10. 7. 11:21
<button type="button" onclick="javascript:clibBoardCopy();">클립보드에복사</button>
function clibBoardCopy(){//클립보드 복사
	var urlInfo = document.createElement("textarea");
	document.body.appendChild(urlInfo);
	urlInfo.value = "<?=$homepage_url?><?=$_SERVER['REQUEST_URI']?>";
	urlInfo.select();
	document.execCommand('copy');
	document.body.removeChild(urlInfo);
	alert('현재 페이지의 URL이 클립보드에 복사되었습니다.');
}

 

Comments