<textarea id="textarea">jsdfkjashdkj ahskdj hjaksd hkajsd</textarea>
<script>
setCaretPosition( document.getElementById("textarea"), 5 );
function setCaretPosition(ctrl, pos) {
if(ctrl.setSelectionRange) {
ctrl.focus();
ctrl.setSelectionRange(pos,pos);
//alert(ctrl.setSelectionRange(pos,pos));
}
else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
//alert(range.moveStart('character', pos));
range.select();
}
}
</script>