Hello (again),
I tried to detect when a Ctrl+F result is inside an iframe. Currently, Firefox’s selection state is the same whether the result is inside an iframe or if the input field has been cleared! I need this for my extension, FineFind.
Possible solutions I’ve tried:
Reading the state of document.activeElement
No matter if the result is inside an iframe or not, activeElement is always the ‘body’ of the main page.
Adding focus and blur event listeners for every iframe and toggling the state of a boolean variable isInsideFrame
When the user clicks inside an iframe, the event triggers, but not when Ctrl+F selects text inside the iframe.
Check the Selection.type property between a result inside an iframe or a cleared search field
In both cases, the type is Caret.
Check the position of the result between a result inside an iframe or a cleared search field
In both cases, the position corresponds to the last element from Selection.type of Range (or at least it seems so).