2

Using Javascript, I need to allow a user to double click a word on a page and retrieve the sentence that it appears in. Not just any sentence, but that specific one. I've toyed with retrieving all sentences that that word appears in and somehow choosing the correct sentence, so maybe that's an option.

I've scoured the web looking for this beast, and I've thought a lot about it. Some have recommended using Rangy but I haven't been able to find the functionality I'm looking for, or even functionality that would help me get where I need to be.

Any ideas?

Vsevolod Dyomkin
  • 9,343
  • 2
  • 31
  • 36
freedomflyer
  • 2,431
  • 3
  • 26
  • 38

1 Answers1

0

You could turn your page into one or multiple read-only textareas, use clever CSS styling to mask it, then use the onselect event as described here: Detect selected text in a text area with javascript

Depends of course, how your page looks like and where it's used.

Community
  • 1
  • 1
Tyron
  • 1,938
  • 11
  • 30