<script> 
function storeCaret (textEl) {
if (textEl.createTextRange) 
textEl.caretPos = document.selection.createRange().duplicate(); 
}
function insertAtCaret (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text =caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?text + ' ' : text; 

else 
textEl.value = text;

function deleteAtCaret (textEl) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
document.selection.clear();
}
//alert(aForm.aTextArea. 

</script> 
<form name=aForm>
<input name=aTextArea size=120 wrap=soft onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" value=这是例子,你可以在这里添加文字、插入文字。> 
<br> 
<input type=text name=aText size=80 value=我要在光标处插入这些文字><br>
<input type=button value=我要在光标处插入上面文本框里输入的文字! onclick="insertAtCaret(this.form.aTextArea, this.form.aText.value);">
<input type=button value=删除选中文字 onclick=deleteAtCaret(this.form.aTextArea); id=button1 name=button1>
</FORM>