I’d like to duplicate the find feature (Ctrl-F in Firefox) for my users.
In other words, a text box that as the user types, it finds the first occurrence of that text, and if they press “Next”, it highlights the next occurrence and moves the page if necessary.
I’m thinking the search input would have to be in a div that remained fixed, and as it found what it was looking for, would insert a named anchor just before it and then follow the hyperlink.
Do you think this can be done?
Finding, highlighting and stepping between instances of text on the page (especially as the text may be split across multiple nodes/elements) properly is tricky. See this question for a find-text-in-page-across-elements function you could adapt.
You can do a noddy version more simply, but that’s likely to be less useful and less usable than the browser’s built-in Find.
Since the browser’s own Find already has the functionality you describe, there’s not really a good reason to do it, unless you need extended functionality the browser can’t support itself. Typically, you resort to this when you have hidden interactive elements on the page that need to be shown when results are found in them.