el代表文本域对象,myvalue代表要录入的字符串。只适用于文本域中焦点追加字符串
function insertAtCursor(el, myValue) { //IE support if (document.selection) { el.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (el.selectionStart || el.selectionStart == '0') { //MOZILLA/NETSCAPE support var startPos = el.selectionStart; var endPos = el.selectionEnd; el.value = el.value.substring(0, startPos) + myValue + el.value.substring(endPos, el.value.length); } else { el.value += myValue; } }