-
2
- #1
Not sure if anyone is interested, but this should allow you to set the cursor position in any text input element ( textarea, various input types, others? ).
/*
obj is the element object
pos is the position in the string the cursor should appear
*/
function setCursor(obj,pos)
{
if(pos<0) throw new Error(666,"Invalid argument in setCursor."
var r = obj.createTextRange();
r.moveStart("character",pos-1);
r.collapse();
r.moveEnd("character",pos==0?0:1);
r.text = r.text;
r.select()
}
jared@eae.net -
/*
obj is the element object
pos is the position in the string the cursor should appear
*/
function setCursor(obj,pos)
{
if(pos<0) throw new Error(666,"Invalid argument in setCursor."
var r = obj.createTextRange();
r.moveStart("character",pos-1);
r.collapse();
r.moveEnd("character",pos==0?0:1);
r.text = r.text;
r.select()
}
jared@eae.net -