1

I have a website that I have written out in plain old HTML and CSS, and want to integrate a search function into it. However, the site is meant to be run offline, from host machines in their local web browsers (i.e. without an internet connection).

I realize that I could easily integrate a search using a mySQL database, though that would require everyone to have a mySQL database running on their computer with the proper data. I was wondering if it would be possible to integrate a search box that wouldn't need to connect to a database (or at least one that didn't require an AMP stack running on each user's local machine).

I have searched around and haven't been able to find a solution to a similar problem. The search doesn't have to be simple, just something that would be able to present the titles of HTML pages in a list (I don't need the content of each HTML document to be searched, just the titles of each page). I was thinking there might be some way to return the titles and descriptions of each page for the search either using each page's <meta> tags, or by having a plain text document at the site root with a listing of all of the pages. Any help would be greatly appreciated!

3 Answers 3

2

There is no way to automatically search through all the HTML files. However, assuming your pages are generated in some way for the user to download, you could also generate a Javascript file with an array of pages/keywords.

For example it could generate some JSON object like var site_index = [ {page:"hello.html",keywords:"hello,world,etc"}, ... ];

Then a function to take an input from a form and find matching pages.

0
  1. Create a sitemap/index XML file including the titles (and perhaps some keywords) for use in search

  2. Apply an XSL template on the sitemap/index XML file which displays a search form

  3. Create a Javascript which responds to search form input with an XQuery to filter/sort the sitemap/index XML file

0

This would work, as long as the machines could have access to a local copy of the necessary php file.

http://www.w3schools.com/php/php_ajax_livesearch.asp

It's pretty simple to implement, also it perfectly matches you criteria

"just something that would be able to present the titles of HTML pages in a list (I don't need the content of each HTML document to be searched, just the titles of each page)."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.