Click to See Complete Forum and Search --> : Javascript Search Engine Question


tomorobi
07-07-2003, 07:26 AM
I have a site using an excellent Javascript-based search engine that I found on the JavaScript Source website. Everything is working exactly as I hoped except for one thing. When you type in a word or phrase to search the site for, it opens a new window and displays the results in that new window. Is there any way to show the results in the current window, perhaps by opening a blank html page and writing the results to it with Javascript? The source code for the search engine is here:

http://javascript.internet.com/miscellaneous/site-search.html

I have no idea how easy or difficult it would be to change this code. I am totally clueless when it comes to anything beyond onMouseOver events. Any help from you masters out there would be great!

Thanks!

David Harrison
07-07-2003, 09:21 AM
you can use a div tag to display your results in, on your page where you want the results in put this:

<div id="results"></div>

and rather than opening a new window, have this to display your results:

var search_results = "No matches found.";

document.getElementById("results").innerHTML=search_results;

whatever you want for your results simply put it in the string called search_results, but if you change it, remember to change it in both places.