Under normal conditions, everyone makes it a few rows in the TextArea control, but there is such a case, it is not using the carriage return, but the character is too wide and the TEXTAREA is automatically changed. It is obvious that the top The method is not feasible.
Here, I encapsulate a method GetTextRange (Num, Areaid). This method only needs to pass the Textarea ID and the line number it needs, you can return to the specified line, for flexibility, there is no return of the specified line here, but return A TRANGE object specified, if you need text, just call the TEXT property of the TRANGE object.
Copy the following code to an HTM file, you can see the effect.
/ ** * added by lxcjie 2004.7.16 * Return the Range object of the specified row * Num is the line number, and is the ID * / function getTextRange (Num, Areaid) {var Range = Document.All Areaid) .CreateTextRange (); var recent = Range.getClientRects (); var left = Re [0] .left; if (num> rect.length - 1 || Num <0) Return; if (Num == 0) {Var right = Rect [0] .right;
Range.Movend ("Character", - Range.Text.Length); While (Range.Offsetleft Range.BoundingWidth Var Range = GetTextRange (Num - 1, Areaid); Range.Movestart ("Character", Range.Text.Length 1); While (Range.Offsetleft Range.BoundingWidth Function GetText (NUM) {var Range = getTextRange (NUM, "Area") {Alert (Range.Text); Range.select ();}} script> head>