Click to See Complete Forum and Search --> : copy in clipboard
vinsa
03-03-2003, 11:05 AM
hi,
I have a textarea and a button of my webpage.
I want, when I click of button to copy
the text in textarea in the clipboard.
Is this possible?
Thanks!
Code One
03-05-2003, 11:27 PM
hey bud yea its possible. It just takes som small jscript and a small html code let me show you what to do:
<html>
<head>
<title></title>
<style>
.highlighttext{
background-color:yellow;
font-weight:bold;
}
</style>
<script language="Javascript">
<!--
var copytoclip=1
function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&& copytoclip==1){ therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}
//-->
</script>
</head>
<body>
<form name="test">
<textarea name="select1" rows=10 cols=35 >blah blah blah</textarea><div>
<a href="javascript:HighlightAll('test.select1')"><img src="cpbttn.bmp" width=21 height=9 border=0 class="noprint"></a><br>
</form>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alright buddy just take this code and paste it right into your editor play with it for a minute till you completly understand why it works, and then just interlace it into your current code.
If you run into any trouble dont hesitate to ask . . cool?
Code One
note:* also notice above were it says:
if (document.all&& copytoclip==1){
The place were the space is should not be spaced, that line should be all one line besides the space between the if and the parenthesis, I had to space the above line becuase if I didnt this would happen:
if (document.all&©toclip==1){
(stupid entity thing)
be cool
Code One