Placing a cursor after text insertion into textarea

ITSROFLTIME

New Member
I know there are smiliar questions but I didn't get my answer.\[code\]function setTextareaSelection(newText) { var selText; newText = "This is a text \n to insert"; var textarea = document.getElementById('textarea'); if (window.getSelection) { var selText = ""; selText = textarea.value.slice(textarea.selectionStart, textarea.selectionEnd); var selEnd = textarea.selectionEnd; var selTextBefore = textarea.value.substring(0, textarea.selectionStart); var selTextAfter = textarea.value.substring(textarea.selectionEnd, textarea.value.length); if (selText != "") { textarea.value = http://stackoverflow.com/questions/4479825/selTextBefore + newText + selTextAfter; textarea.setSelectionRange(selEnd, selEnd); } }}\[/code\]I want to place mouse cursor after the inserted text.
Firefox onlyOnline example:link text
 
Top