Html Textarea: Is It Possible To Change Cursor Position?
Is it possible to change cursor position in textarea element using Javascript code?
Solution 1:
YES
function SetCursorPosition(pos)
{
// HERE txt is the text field namevar obj=document.getElementById('<%= txt.ClientID %><%= txt.ClientID %>');
//FOR IEif(obj.setSelectionRange)
{
obj.focus();
obj.setSelectionRange(pos,pos);
}
// For Firefoxelseif (obj.createTextRange)
{
varrange = obj.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
FROM :: http://shawpnendu.blogspot.com/2009/03/javascript-how-to-setget-cursor.html
Solution 2:
This post may help you Caret position in textarea, in characters from the start
Post a Comment for "Html Textarea: Is It Possible To Change Cursor Position?"