类似qq回复一样,某人评论之后,在对评论进行回复之后,将光标定位到文本之后:
function set_focus()
{
el=document.getElementById('guestbook_editor');
//el=el[0]; //jquery 对象转dom对象
el.focus();
if($.support.msie)
{
var range = document.selection.createRange();
this.last = range;
range.moveToElementText(el);
range.select();
document.selection.empty(); //取消选中
}
else
{
var range = document.createRange();
range.selectNodeContents(el);
range.collapse(false);
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
}
参考地址:http://chwjbn.blog.163.com/blog/static/1038799201310762620681/