解决方案 »
- 如何用jquery 创建一个dialog dialog中有一个textbox可以输入和修改数据
- weebox显示问题
- 急~~~~~~~~~~~求一个像http://www.ifeng.com/页面里面效果的层
- 用 table 的 insertRow() 和 insertCell() 增加表格行时,所在 div 怎么会跳到页面下方去呢?
- 请问javascript的节点名nodename问题?
- 请帮我看一下这段代码哪里有问题
- ·小问题一个,请高手点解一下。
- javascript中怎么把字符转换成数字??用哪个函数??
- 如何使用ActiveX中的函数?
- 如何将网页窗口定时关闭,100分请教!!!!
- javascript class难题,高手解答一下
- 关于jquery里的Init
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>