[Project_owners] collecting text near a mouse click

Neil Deakin enndeakin at sympatico.ca
Thu May 4 15:10:19 EDT 2006


John Woodell wrote:
> I have an extension that process a selection...
> var str = new String(window._content.document.getSelection());
>
> I'd like to be able to just click on the some part of the page,
> and collect the text just before and after the click coordinates,
> then to something with that text from a right-click menu.
>
> Has anybody figured out a way to do this?

You can use the rangeParent and rangeOffset properties of the event to 
get the textnode and offset into the text that was clicked on.

/ Neil



More information about the Project_owners mailing list