I have to get carat status within the text field (Internet Explorer only). I have this:
document.activeElement.focus (); Var sel2 = document.selection.createRange (); Sel2.moveStart ('character', -document.activeElement.value.length); Var caretPos = sel2.text.length; Warning (caretPos); If Tethertera is a line then I get the right result, but if there are many lines then the result is wrong because the new line has extra characters which is not visible ... How do I correct Can I get status values (without \ r \ n and delete such a dirty work)?
I argue that when calculating the position of selection borders / cursor, line as two letters Line breaks are the right approach. Basically, those two characters are in the \ r \ n text that are present in the value property of textarea and are in the values that are submitted to the server.
The only argument is that I can look for a line break as a line:
- Compatible with other browsers
- IE
Texture of the
I think the line breaks as a character. First of all, IE is already incompatible with other browsers. The number of line breaks is counted as one of two characters instead of the second, IE's TextRange character-based form S anyway a bit crazy, so they are causing problems.
I think that considering the selection / carerate situation, it is a complete understanding of the relative position of the text in the text. It allows easy manipulation of text.
There are two main functions here: for the first time the only Textera Selection / Carrying Status is happening, which I have seen that works well with all line breaks You can find it here: Second, here A complementary setSelection is the function:
Function OffsetTorang characterTrack (L offset) {Offset Off - (L.V. Slous (0, Offset) .split (" R \ n ") Length - 1); } Function Set (L, Off Offset, Endoffet) {var range = el.createTextRange (); Var startCharMove = offsetToRange sensor main (al, startoffset); Range.collapse (true); If (startoffset == endOffset) {range.move ("character", startCharMove); } And {range.moveEnd ("character", offsettorangcharactermov (L, endoffet)); Range.movest ("character", beginning of the month); } Category. Select (); }
Comments
Post a Comment