What I like to do is to programmatically trigger the on-page search functionality of my browser from JavaScript.
I.e. when a page is loaded and the the user presses Ctrl+F, a search field is opened and the user can enter a search term. This usually results, depending on the used browser, in all occurances being highlighted.
I want to do the same on my page:
While I think it is not possible, due to possible security-risks, I still want to be sure.
Therefore my question:
Is it possible to programmatically trigger the on-page search function of a web browser?
(If there is no general API, maybe there are browser-specific ways of doing it)
There is the non standard window#find
, currently supported by Chrome, FF, and Safari. However, future support is not guaranteed:
setTimeout(function() {
find('text');
}, 1000);
<p>I'm the text</p>