Range and Selection Issues in IE and FF

Hello. Faced a problem that I have a headache for a long time … Description of the problem: if you select the word not exactly from beginning or not exactly up to the end of the word (visually the selection remains correct, but by holding down the mouse button selecting the text and not releasing the cursor to the left, etc. without highlighting an extra space, but slightly exceeding the scope of the selection) like here …

in IE and Firefox
in the “Range” object:

  1. If you select from the left to the right, and on the left make a selection exactly by the word, and on the right a little go for this word (selection does not visually change) - comes the startContainer - the selected item, and the endContainer does not come up correctly (common parent of element for example)
  2. from right to left - on the contrary, end endContainer - ok, startContainer - incorrect
    in “Selection” object
  3. left to right anchorNode - selected element, focusNode - not correct
    2.and vice versa

for create range using

selection.getRangeAt(0)

for selection

window.getSelection() (tried document.selection - the same story)

Maybe somebody could help with this behavior…

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.