html 클립보드에 복사 샘플

Copyclipboard

Copyclipboard02

<html>

<head>
<title>클립보드에 복사 샘플 </title>

<script type="text/javascript">
<!--
function toclip(id)
{
 var idxs = document.getElementById(id);
 if(idxs.value==''){ document.body.focus(); return; }
 idxs.select();
 var clip=idxs.createTextRange()
 clip.execCommand('copy');
 alert('클립보드에 복사되었습니다');
}
//-->
</script>
</head>

<body>
    <input type="text" id="textclip" value=" Clip text 1234567890" />
    <br/><br/>
	1.<INPUT type="button" onClick="toclip('textclip'); return false;"  value="클립보드에 복사">
    <br/><br/>
	2.<a href="#" onClick="toclip('textclip'); return false;">클립보드에 복사</a>
	
</body>
</html>