Home Miscellaneous
Site Search (Source)
Here is the JavaScript codings to put a Search Engine on YOUR site. Copy the codes to your site, enter the listings information, and you've got your own site search engine!
Working Example:
http://javascript.internet.com/miscellaneous/site-search.html
Quick Download:
http://javascript.internet.com/miscellaneous/site-search.zip
The JavaScript Source: Misc.: Site Search
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as NotePad or SimpleText) and save (Control-s or Apple-s). The script is yours!
The JavaScript Source: Misc.: Site Search (Display Frame)
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as NotePad or SimpleText) and save (Control-s or Apple-s). The script is yours!
<!-- TWO STEPS TO INSTALL SITE SEARCH (DISPLAY FRAME):
1. Create a new HTML document named site-search-display.html
2. Put first code into the HEAD of site-search-display.html -->
<!-- STEP ONE: Create site-search-display.html -->
<!-- STEP TWO: Copy this code into the HEAD of site-search-display.html -->
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function initArray(){
this.length=initArray.arguments.length;
for (var i=0;i<this.length;i++){
this[i]=initArray.arguments[i];
}
}
var sr=new initArray("4b","5b","8b","8b");
function doSrch(){
if (sr[0]=="4b"){
parStr();
}
findw = parent.main.document.searcher.findword.value
findw=findw.toLowerCase();
disp = "";
document.write('<HTML><BODY BGCOLOR="white">'
+'<CENTER><FORM NAME="isn"><TABLE BORDER=0 '
+'WIDTH=486><TR><TD VALIGN=TOP></TD><TD><SE'
+'LECT NAME="isn1" SIZE=6>');
flg=2; // Set flag to "no matches found"
for (i=0;i<stp;i++){
fold=sr[i].toLowerCase();
if (fold.indexOf(findw)>-1){
pos=sr[i].indexOf("~");
pos1=sr[i].indexOf("|");
disp="<OPTION VALUE='"+sr[i].substring(0,pos);
if (flg!=3){
// disp+='<TD><SELECT NAME="isn1" SIZE=6>'+disp;
disp+="' onClick='' SELECTED>";
}
else{
disp+="' onClick=''>";
}
disp+=sr[i].substring(pos+1,pos1);
document.write(disp);
flg=3; // Set flag to "matches found"
}
}
if (flg!=2){
document.write('</SELECT></TD><TD VALIGN=TOP'
+'><INPUT TYPE="button" NAME="button" Value'
+'=" Select and Go " onClick="doloc(this.fo'
+'rm)"><BR>');
}
document.write('<BR><FONT COLOR="red"><B>');
if (flg!=3){
document.write('</TD><TD VALIGN=CENTER><FONT '
+'COLOR="red"><B><BR>I\'m sorry. I found no matches'
+' for "'+findw+'".<P>Feel free to perform'
+' another search!</B></FONT>');
}
else{
document.write('The selection(s) at left w'
+'ere<BR>found using keyword "'+findw+'".');
}
document.write('</B></FONT></TD></TR></TABLE>'
+'</FORM></BODY></HTML><P>');
}
function parStr() {
srs=parent.find;
var i=0;
while (srs.indexOf("*")>0) {
pos=srs.indexOf("*");
sr[i]=srs.substring(0,pos);
srs=srs.substring(pos+1,srs.length);
i++;
stp=i;
}
}
function doloc() {
durl=(document.isn.isn1.options[document.isn.isn1.selectedIndex].value);
/* This next line will target the selection
to the main pane of your frameset. */
parent.main.location.href=durl;
/* But if you wish to target the selection to the top
(just as you would use <A HREF="filenm" TARGET="_top">)
simply uncomment this next line and use it instead:
parent.location.href=durl;
and comment out the line now being used above. */
}
// End -->
</SCRIPT>
<BODY BGCOLOR=white>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
if (parent.test != "a") {
doSrch();
}
// End -->
</SCRIPT>
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 2.75 KB -->
The JavaScript Source: Misc.: Site Search (Main Frame)
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as NotePad or SimpleText) and save (Control-s or Apple-s). The script is yours!
<!-- THREE STEPS TO INSTALL SITE SEARCH (MAIN FRAME):
1. Create a new HTML document named site-search-main.html
2. Put first code into the HEAD of site-search-main.html
3. Put the last code into the BODY of site-search-main.html -->
<!-- STEP ONE: Create site-search-main.html -->
<!-- STEP TWO: Copy this code into the HEAD of site-search-main.html -->
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function doSrch(){
parent.test="b";
parent.results.location.href="site-search-display.html"
}
// End -->
</SCRIPT>
<!-- STEP TWO: Copy this code into the BODY of site-search-main.html -->
<BODY>
<CENTER>
<FORM NAME="searcher" onSubmit="doSrch();return false">
<TABLE BORDER=0 WIDTH=486>
<TR>
<TD ALIGN=CENTER><B>Search Our Site For Topic Words</B>
<P>Type Search Word Here: <INPUT TYPE="text" NAME="findword" VALUE="" SIZE=20>
<INPUT TYPE="button" NAME="button" VALUE=" Search " onClick="doSrch();"></TD>
</TR>
</TABLE>
</FORM>
<!-- Put any other content for your page here -->
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.18 KB -->
Did you use this script? Do you like this site? Please link to us!