Click to See Complete Forum and Search --> : copy text


vinsa
03-04-2003, 01:52 PM
hello, first sorry for my english.
I need from a javascript.
In my webpage have a textarea and a button. I want when i click the button, to copy the text in textarea in the clipboard.
Is this possible?

pyro
03-04-2003, 02:02 PM
It is possible in IE, with document.execCommand("Copy")

dabush
03-04-2003, 02:10 PM
<html>
<head>
<script language=JavaScript>
<!--
function copyText(box)
{
var range = box.createTextRange();
range.execCommand("Copy");
}
// -->
</script>
</head>
<body>
<form name=myform>
<textarea name=mytextarea rows=10 cols=50></textarea><br>
<input type=button value="Copy Text" onClick="copyText(window.document.myform.mytextarea);">
</form>
</body>
</html>