How to use textRange Object to move the cursor?
Posted on 2001-08-09
Using IE 5.5, when the user gives focus to an empty text or textArea, I automatically place a default value in the box like so:
function myOnFocus ()
var o = event.srcElement;
if ("" == myTrim(o.value))
o.value = "default value";
// Location A
The problem is that the text-insertion cursor appears at the beginning of this text and I would like it to appear at the end.
I can select the text using the following code at Location A:
var r = o.createTextRange();
Documentation suggests that the following code would then remove the selection and move the cursor to the end, but it does nothing that I can detect:
Can anyone suggest how I might move the cursor to the end of the text using the TextRange object or by some other means?
Thank you all :)