<style>
.highlighttext{
background-color:yellow;
font-weight:bold;
}
</style>
<script type="text/javascript">
/***********************************************
* Select and Copy form element script- By Dynamicdrive.com
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
function selectcopy(fieldid){
var field=document.getElementById(fieldid) || eval('document.'+fieldid)
field.select()
if (field.createTextRange){ //if browser supports built in copy and paste (IE only at the moment)
field.createTextRange().execCommand("Copy")
alert("Value copied to clipboard!")
}
}
</script>
<form name="test">
<a class="highlighttext" href="javascript:selectcopy('test.select1')">Select All</a><br>
<textarea name="select1" rows=10 cols=35 >This is some text. This is some text. This is some text. This is some text.</textarea>
</form>
Quelle: www.dynamicdrive.com