views:

154

answers:

1

I'd like to be able to figure out the text that a user highlights on a given web page (we use jQuery if that helps), to capture and store in a database.

Politico.com does this in a pretty slick way -- if you highlight text on an article page there and copy it, you copy not just the highlighted text but also a link back to the politico.com article with an ID that is associated with the text you highlighted. In this example, I highlighted text in the third paragraph before copying and pasting, which inserted the id/hash/whatever "ixzz0TNvdwh0h".

Anybody know how this is done?

A: 

Here is code snippet that will take the selection from the browser using a method called window.getSelectedText Selected Text From Code Toad

Chris Gutierrez