i have one static site in html...
can any one please help to search the whole static site with search textbox...
Any ideas and help would be appreciated...

Dani AI

Generated

This thread from about adding a search box to a static HTML site has a few practical paths. Contributors noted limitations and partial approaches (, , ). The three realistic choices are: ship a prebuilt search index that the site can query, plug in a hosted search service, or add a tiny server-side/search-function that serves an index — each has trade-offs around size, freshness and hosting.

A common, low-cost workflow for small-to-medium sites is to generate a compact JSON index at build time and run the search in the browser. Steps: extract title/url/text for each page into index.json, serve it gzip-compressed, then load and query it only on the search page. Use a light search library such as Lunr.js or Fuse.js to handle tokenizing and ranking. Minimal example of the index shape and a fetch-and-search pattern:

[
  {"id":"page1","url":"/page1.html","title":"Page One","body":"plain text content"}
]
fetch('/index.json')
  .then(r => r.json())
  .then(d => {
    var idx = lunr(function () {
      this.field('title'); this.field('body');
      d.forEach(doc => this.add(doc));
    });
    var results = idx.search('your query'); // map refs back to documents
  });

If the index would be large or you prefer outsource, consider a hosted option (search box + crawler or API) such as Google Programmable Search Engine or Algolia DocSearch — they trade setup/cost for scale and relevance tuning. Key cautions: keep the index focused (only searchable text), automate index regeneration, gzip or lazy-load the file, watch CORS and caching, and test relevance for your content and language.

Recommended Answers

All 6 Replies

Any ideas......??????

how it possible to searching with a text box, its not possible

how it possible to searching with a text box, its not possible

hello..
i heard that its possible by saving our file content in msaccess and doing file search on that...

yes we can search with the help of javascript or xml i found a file but i didn't remember from which site. i did worked on it but failed to modify according to my requirement
i knew php but dont have much knowledge javascript,experts here may tell us where we have to make modifications to configure it according to user requirement

yes...
thanks praveen...

With a static site, it would involve some sort of tie with your browser's search feature. Real searches are tied to a database, and since you don't have a tie there it would need to access a search engine that has crawled your site.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.