: Hello I was wondering if anyone could tell me where i could get some code to put a search bar on my website nothing fancy, just something that will search my main directory for files that i need any help would be most appreciated.
:
Javascript cannot open and read external files, so you'll have to create a database of keywords for each of those files in your script. Searching through those words can be done using the indexOf() method of each keyword entry. Here is an untested sample code:
var keyWords = new Array;
keyWords[0] = 'www.google.com|search,websearch,find';
keyWords[1] = 'www.programmersheaven.com|javascript,delphi,programming,pascal';
function performSearch(searchstr)
{
for (i=0; i < keyWords.length; i++)
{
if (keyWords[i].indexOf(searchstr) != -1)
{
location.href = keyWords[i].split('|')[0]; // go to the new location
}
}
alert('No matches found');
}