複製程式碼 程式碼如下: <BR>function Button4_onclick(obj) { <BR>obj.focus(); <BR>var rng=document.selection.createRange(); <BR>rng.setEndPoint("StartToStart",obj.createTextRange()); <BR>var eng=document.selection.createRange(); <BR>eng.setEndPoint("EndToEnd",obj.createTextRange()); <BR>var kone = document.getElementByIdx("Text1"); kone.value=rng.text "插入字元" eng.text; <BR>} <BR> value="button" onclick="return Button4_onclick(Text1)" /> 複製程式碼 程式碼如下: Inherits="SJLERP.WebForm1" %> <BR>function setCaret(textObj) { <BR>if (textObj.createTextRange) { <BR>textObj.caretPos = document.selection.createRange().duplicate(); (textObj, textFeildValue) { <BR>if (document.all) { <BR>if (textObj.createTextRange && textObj.caretPos) { <BR>var tPos = textObj.caretPos) { <BR>var tPos = textObj.caretP. .charAt(caretPos.text.length - 1) == ' ' ? textFeildValue ' ' : textFeildValue; <BR>} else { <BR>textObj.value = textFeildValue; <BR>} <BR>textObj.value = textFeildValue; <BR>} <BR>} else {🎜> if (textObj.setSelectionRange) { <BR>var rangeStart = textObj.selectionStart; <BR>var rangeEnd = textObj.selectionEnd; <BR>var tempStr1 = textObj.value.substring(0, rangeStart); textObj.value.substring(rangeEnd); <BR>textObj.value = tempStr1 textFeildValue tempStr2; <BR>} else { <BR>alert("This version of Mozilla based browser does notnport set); 🎜>} <BR>} <BR> onselect="setCaret(this);" onclick="setCaret (this);" onkeyup="setCaret(this);" >範例範例Forget Never 子範例範例asp.net onclick="insertAtCaret(this.form.tarea,this.form.textfield.value);"/>