-1

Here is my requirement:

I have some HTML files in my Server, and a master HTML file containing Search Textbox and Submit button. User will be entering a keyword in that Textbox, if the word exists, it must show that word highlighted and the URL where it is present. Else display word not found.

Thanks in advance...

abhi abhi
  • 181
  • 1
  • 2
  • 10
  • You might find this useful, I answered this question yesterday http://stackoverflow.com/questions/15597736/filter-search-for-ul/15597786#15597786 – Daniel Imms Mar 25 '13 at 06:49
  • 1
    Which part is the one you're having problems with specifically? – JJJ Mar 25 '13 at 06:50
  • @Juhana I am not understanding how to implement this one, can JavaScript read HTML files present on Client machine? NO I guess. – abhi abhi Mar 26 '13 at 04:59

1 Answers1

1

Ordinarily, you'd need to do this on the server-side, but this can be done on the client.

Use scripting to pull in all of the HTML files and then index them for keywords, then allow the user to search this in-memory index and redirect the browser as appropriate.

The downside is that client-side initialization and index-building is going to take at least a few seconds.

Otherwise, you'd implement search on the server-side, do you have PHP, ASP.NET, JSP etc enabled?

Or, why not just let Google do the searching for you with the site: term?

Dai
  • 141,631
  • 28
  • 261
  • 374
  • Thanks for your answer. Here the files will be present on Client machine no Server is involved, so I've tagged it in javascript :). And can you post some example or required docs if there are any? I would be very thankful.. – abhi abhi Mar 25 '13 at 07:07
  • @abhiabhi Why does the question say "I have some HTML files in my Server" if there is no server? – JJJ Mar 25 '13 at 07:09
  • @Juhana hahaha good catch, you cornered me :D, right now I am working on my machine which is an Apache enabled Server. But this work of searching files will be present on the Client machine which doesn't have any Apache or atleast Internet. – abhi abhi Mar 25 '13 at 07:12
  • So Dai, you mean I need a buffer to pull in all the HTML files in one hop and then start searching from file-1 to file-n order? – abhi abhi Mar 25 '13 at 07:56
  • 1
    Not a buffer; I'd load the documents into a DOM, then index the DOM, then search the built index. Searching documents directly would be a mistake. – Dai Mar 25 '13 at 08:02
  • Well, is it the only way or anyother way to work around? Thanks. – abhi abhi Mar 25 '13 at 10:06