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

2

2

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

Helicograph answered 6/1, 2011 at 20:4 Comment(0)
B
4

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.

Baudelaire answered 6/1, 2011 at 20:13 Comment(2)
Thanks Felix! will try this outHelicograph
The selection can of course be modified with the keyboard as well as the mouse.Fausta
F
2

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.

Fausta answered 10/1, 2011 at 20:54 Comment(2)
Hi neil can you please elaborate on this.Partite
For others interested see this topic here I will post solution here: https://mcmap.net/q/243319/-observe-for-highlightPartite

© 2022 - 2024 — McMap. All rights reserved.