<script type="text/javascript">
function test(str){
var tc = document.getElementById("content");
var tclen = tc.value.length;
tc.focus();
if(typeof document.selection != "undefined")
{
document.selection.createRange().text = str;
}
else
{
tc.value = tc.value.substr(0,tc.selectionStart)+str+tc.value.substring(tc.selectionStart,tclen);
}
}
</script>
<p><input type="button" onClick="test('插入文字')" value="插入文字" /> <br />
<textarea id="content" rows="7" cols="81" name="content">这里是文本域</textarea></p>