Getting selected text position

s = window.getSelection();

Returns a Selection. So try

s = window.getSelection();
oRange = s.getRangeAt(0); //get the text range
oRect = oRange.getBoundingClientRect();

oRect will be the bounding rectangle in client (fixed) coordinates.

Leave a Comment