On my private homepage I have implemented a search function (a freeware search engine browsing all pages on the site).
The results, if any, are presented on a one page with links to the corresponding pages (pages with search hits).
If I click on a link, the linked page is opened and all occurrencies of the search term on this page are highlighted.
I assume they are highlited via standard browser functionality by passing xxx.html?q=<search term> to the browser.
My site is HTML (not PHP).
Now I want to scroll the page to (or better near, lets say 5..10 lines in front of) the first occurrence of the search term.
Is there a short and crispy method to realize that behavior?
Java Script is ok for me, but I’m not very competend in programming JS.
Harry S is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1