0

Anyone know if there is a trigger for this or variable I can poll to check if something is currently highlighted on the page?

1 Answers1

0

You can check if a "mouseup"-event was fired and then get the currently selected text:

document.onmouseup = ()=>{
  selection = window.getSelection().toString()
    if(selection){
      alert(`"${selection}" is highlighted`)
    }
}
Select me!

(Read Selected text event trigger in Javascript)

benS
  • 71
  • 1
  • 7