function AddText(txt) {
obj = document.getElementById("test");
selection = document.selection;
obj.focus();
if (typeof obj.selectionStart != "undefined") {
var opn = obj.selectionStart + 0;
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;
}
}
posted on 2009-03-05 21:44
汪杰 阅读(271)
评论(2) 编辑 收藏 引用 所属分类:
javascript