[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Javascript search engine interface



There's a javascript form that interfaces many search engines (over 40)
located at http://www.gatech.edu/amnesty/writingtest.html  (click on 
"javascript netsearch" on the right frame or go directly to
http://www.gatech.edu/amnesty/search.html )

A code snippet is below. Feel free to borrow it, steal it, improve it, etc.
anything you like.

<script language="JavaScript">
<!--

function Plusify(items) {
var plussed = "";
  for (var t = 1 ; t <= items.length ; t++) {
    if (items.substring(t-1,t) == " ") {
    plussed+="+";
    }
    else {
    plussed+=items.substring(t-1,t);
    }
  }
return plussed;
}

function doSearch() {
      var terms, index, place;
      terms = Plusify(document.searchforit.query.value);
      index = document.searchforit.service.selectedIndex;
      place = document.searchforit.service.options[index].value;
      place+=terms;

      if (notEmpty(terms))   {
//       location.href=place;
          window.open("","main2");
          window.open(place,"main2");
      }
}

function notEmpty(word)  {
  if (word == "" || word == null) {
   self.status="ENTER SEARCH TERMS";
//   alert("Enter search terms");
   return false;
  }
  else {
   self.status = "SEARCHING FOR:  " + word;
   return true;
  }
}

//-->
</script>


-- 
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Doug Holton, mailto:dlh@cc.gatech.edu
EduTech, College of Computing, Georgia Tech, Atlanta, GA 30332-0280
http://www.prism.gatech.edu/~dh91/