Kapil
Kapil

Reputation: 572

Firefox addon - how to listen to a text highlight event in a webpage

I am writing an addon which needs to do capture the no of times someone has highlighted any text on a webpage. Is there any way I can listen to this event?

Thanks, Kapil

Upvotes: 2

Views: 501

Answers (2)

Neil
Neil

Reputation: 55402

You could add a selection listener. The Source window (viewSource.js) does this so that it can keep the row and column number up-to-date.

Upvotes: 2

Felix Kling
Felix Kling

Reputation: 816580

There is not a particular event for this. But you can listen to the mouseup event and check whether the selection returned by window.getSelection() is not empty and/or whether it differs from the previous selection.

Upvotes: 4

Related Questions