Making a JavaScript Search Engine, so far as JavaScript is concerned, is actually quite easy.

<html>
<head>
<title>JavaFILE</title>
<base target="leftframe">
</head>

<body BGCOLOR="#ffffff" link="#CC0033" vlink="#333399" alink="#FF0000" <!--content start-->

<table WIDTH="96%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
  <tr> <script
    LANGUAGE="JavaScript">

    <!-- Hide Script from Old Browsers
/* 

        [].

        Java Search Engine
        .
        Version 2.0
*/

    Keyword = new Object();
    Descrip = new Object();
    Address = new Object();

// Keyword[0] = n  (where n is the number of keywords which can be searched
Keyword[0] = 6

// Each entry is split into
// Keyword[n] = text (where text is the keyword of which the entry is to
// be searched by  (type Keywords in lowercase)
// Descrip[n] = text (where text is the description associated to this entry
// Address[n] = text (where text is the URL associated to the entry
//  n is the entry number.

Keyword[1] = "java"
Descrip[1] = "Professional Web Designs."
Address[1] = "http://www.bestsitesplus.com"

Keyword[2] = "free"
Descrip[2] = "free java!"
Address[2] = "http://www.bestsitesplus.com"

Keyword[3] = "members"
Descrip[3] = "join."
Address[3] = "http://www.bestsitesplus.com"

Keyword[4] = "mousetrail"
Descrip[4] = "free javascripts!"
Address[4] = "http://www.bestsitesplus.com"

    function checkDatabase() {

      var Found = false
      var Item = document.forms[0].searchfor.value.toLowerCase();

stats='toolbar=no,location=no,directories=no,status=no,menubar=no,height=300,width=300,'
stats += 'scrollbars=yes,resizable=yes'
MsgBox = window.open ("","msgWindow",stats)
MsgBox.opener = window;
MsgBox.opener.name = "opener";
MsgBox.document.write("<head><title>Search Results</title></head>");
MsgBox.document.write ("<body bgcolor=white text=black link=blue vlink=darkblue alink=blue><H2><CENTER><font face=arial>Search Results</CENTER></H2>")
MsgBox.document.write ("<font size=3><b><center>For the keyword:  "+Item+"</center><hr width=50%></b></font>");
        for (var i=1; i <= Keyword[0]; i++) {
        if(Item == Keyword[i]) {
          Found = true;
         MsgBox.document.write ("<li><font face=arial><font size=2><b>"+Descrip[i]+"<BR><A HREF="+Address[i]+" target='opener'>Click Here To Go There</A></font></font>") 

        }
      }
      if(!Found)
MsgBox.document.write ("<H4>Nothing Found</H4>")
// Leave the line below intact if you want to legally use this script
MsgBox.document.write ("<FORM><CENTER>")
MsgBox.document.write ("<font size=2><font color=arial><INPUT type='button' value='Close' onClick = 'self.close()'></font></font>")
MsgBox.document.write ("</CENTER></FORM>")
MsgBox.document.write ("<H6><small><small><small><b></b><font color=white><font face=arial><font size=1><font color=black> <br> </font></font></small></small></small>")
     }
    //    --> 

</script> </font><a
    href=""><font size="3"> </font></a><font FACE="ARIEL,HELVETICA" SIZE="-1"></p>
    <form NAME="form1">
      <b><div align="center"><center><p>Search for:</b><br>
      <input TYPE="text" NAME="searchfor" VALUE="" SIZE="20"><b><input type="button"
      value="Search" align="absmiddle" onClick="checkDatabase()"></b><br>
      <br>
      <font face="Arial" size="2">To test this search engine, search for <strong>'Java'</strong>.</font></font>
      </p>
      </center></div>
    </form>
    </td>
  </tr>
</table>
<!--content stop-->
</body>
</html>
 

Leave a Comment