Web/Javascript

copy & paste

aucd29 2013. 9. 26. 21:28
<script language="JavaScript">
<!--
function copy()
{
textRange = document.body.createTextRange()
textRange.moveToElementText(txt1)
textRange.execCommand("Copy")
}

function paste()
{
textRange = document.body.createTextRange()
textRange.moveToElementText(txt2)
textRange.execCommand("Paste")
}


//-->
</script></p>

<table align="center" class="fon1" border="0" cellpadding="2" cellspacing="0">
<tr>
<td>
<p align="center">여기서 복사<br>
<textarea id="txt1" rows="9" cols="26">복사 버튼을 누르시면
여기있는 내용이 복사가
된데요 ^^</textarea></p>
</td>
<td>
<p align="center">여기다 붙여넣기<br>
<textarea id="txt2" rows="9" cols="26">붙여넣기 버튼을 누르면
왼쪽에서 복사된 내용이
여기로 붙여넣기가 됩니다.</textarea></p>
</td>
</tr>
</table>

<p align="center">
<input type="button" value=" 복 사 " onclick="copy()">
<input type="button" value="붙여넣기" onclick="paste()">
<input type="button" value="위 내용 지우기" onclick="txt1.value=' ';txt2.value=' '">
</p>



* 소스보기 Ver 1.0 Made By 달팽이홈2 *