Some operation summary of cursor
The RANGE operation under IE is much better than mozilla, and only the operations under IE are discussed here.
Here is the characteristics of several cursor positioning:
1. The cursor does not change
Direct Obj.focus (), the cursor will return the previous position, that is, the location is constant
2. Cursor in the forefront
Var r = obj.createtextExTRANGE ();
r.collapse ();
R.select ();
Use this method to make the cursor in the Input box
3. Cursor in the final
Var r = obj.createtextExTRANGE ();
R.Collapse (false);
R.select ();
With this method, you can stop the cursor at the end of the input box.
4. Select some of the contents of the INPUT box requires the range of the MoveStart or Movend method, which uses the detailed method to use the MSDN.
Function SL (O, M, N) {
Var = o.createTextRange ();
Rt.collapse ();
Rt.select (); // light timber
Var r = document.selection.createralge ();
R.Collapse (false);
R.MoveStart ("Character", M); // Starting from M
R.Movend ("Character", N); // Select N-bit
R.select ();
}
script>
5. Remove the movement and location of the cursor, this is what people often ask
Function setpos (Obj, N)
{
Obj.focus ();
Var r = document.selection.createralge ();
R.Collapse (false);
R.Move ("Character", N);
R.select ();
}
Function getPOS (OBJ)
{
Obj.focus (); / / cursor position constant
Var r = document.selection.createralge ();
R.Collapse (false);
R.SETENDPOINT ("StartTostArt", Obj.createTextRange ());
Alert (R.Text.length);
}
script>