本帖最后由 wang_feng1984 于 2011-06-21 15:02:27 编辑

解决方案 »

  1.   

    <input type="text" onblur="onblurAction();" id="txtContent" size="50" value="12345689" onclick="InsertString('txtContent', '{Good}');"> 
      

  2.   

    我这有个兼容IE 和FF的<script>
        function AddText(txt) {
        obj = document.getElementById('message');
        selection = document.selection;
        checkFocus();
        if(typeof(obj.selectionStart)!='undefined') {
        //document.getElementById('logs').innerHTML+=obj.selectionStart+' '+obj.selectionEnd;
        obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
        } else if(selection && selection.createRange) {
        var sel = selection.createRange();
        sel.text = txt;
        sel.moveStart('character', -txt.length);
        } else {
        obj.value += txt;
        }
        }
         
        function checkFocus() {
        obj.focus();
        }
    </script>
    <textarea id="message" name="message" onClick="AddText('test')">12345</textarea>