Search code examples
javascripthtmldynamicfull-text-searchdynamic-html

JS - How to search in an HTML page that hasn`t been created yet? (Dynamic HTML)


I have a JSON file with links to html pages in my project folder, I create the HTML content dynamically in the browser after the user clicks a button. However, I try to make a search engine in all of these dynamic pages, but can`t think of a way to do it, because the page has not been displayed yet.

Is there any way I can grab the innerHTML of an HTML page in my project folder, and add it to the search engine array?

Thanks a lot, Cheers

EDIT: Forgot to mention that this is a web app, where the user navigates to the final document he needs (each process has child processes, and grandchild processes), so I have alot of content, this is why I am using the JSON and create the content dynamically instead of writing every single html page... (I porbably have about 200 pages)


Solution

  • You could get the html with XMLHttpRequest. But if you've got a lot of files or a lot of content that would be way too many requests. I would do it server side with nodejs or php or some other server side language.