How to get pixel-position of window.selection

96 views Asked by At

I have been able to get the selection from the red box with this code:

 var selection = window.getSelection().getRangeAt(0);

Which returns a startOffset and a endOffset corresponding to the characters from 0-14 (in this picture) enter image description here

But how do you get the same kind of area-selection of a image? The desired output should be like the example below

enter image description here

0

There are 0 answers