Site Search Script

wheinrome

New member
Nov 20, 2006
307
8
0
I've got a 45 page site that is static html and need a good site search script suggestion. I've seen a few scripts that search mysql databases but not static html files. I don't want anything Google related on my site so Google custom search is out of the question. Any suggestions?
 


If you have access to a database, write a script to crawl your static pages and store all non-stop words in a database for each URL. Then you can use a standard MySQL search engine. You could also write to flat files if you don't have access to a database, but I'm assuming you don't want to write any custom scripts yourself.

Otherwise just search around for a PHP based static HTML search engine. I'm not going to do the work for you, but there must be at least 1 out there.
 
Javascript has a .search() function that will search for matching strings(words or characters) or regExp. You have to loop through the elements in the DOM tree, check against the word, if none continue to the next node searching.

Here's a basic implementation that will search the words on the current page Dynamic Drive DHTML Scripts- Find In Page Script

You would need to customize it to also search through the other pages of your site, and write a custom function to populate a div with the returned links to the results on the other pages.

But it would still probably be pretty simple.

Here's a pretty good tutorial for a client side search engine Chapter 1 The Client-Side Search Engine with more features than the one dynamic drive one.