<HTML>
     <HEAD></HEAD>
 <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;
     }
     </script>
  <BODY>
 <FORM NAME="aForm">
 <TEXTAREA NAME="aTextArea" ROWS="5" COLS="80" WRAP="soft"
   onselect="storeCaret(this);"
   onclick="storeCaret(this);"
   onkeyup="storeCaret(this);">测试测试测试测试测试测试
 </TEXTAREA>
<BR>
<INPUT TYPE="text" NAME="aText" SIZE="80" VALUE="#Page# ">
<BR>
<INPUT TYPE="button" VALUE="insert" onclick="insertAtCaret(this.form.aTextArea,this.form.aText.value);">
 </FORM>
 </BODY>
</HTML>