SearchToHTML ist eine effiziente Suchmaschine für die eigene Homepage. Die Suchmaschine durchforstet die in den Parametern eingetragenen Webseiten nach den Suchbegriffen und gibt die Treffer als dynamisch generierte HTML Seite aus.
Es empfiehlt sich, die Suchmaschine in ein Frameset einzubauen.
Diesen Code in das Such-Fenster eintragen <applet code="SearchToHTML.class" width=360 height=60>
<param name="files" value="main.htm, news.htm, navigate.htm, banner.htm, spiele.htm">
<param name="target" value="main"> </applet>
Die Ausgabe der Treffer wird in das im Applet-Code genannte Fenster (hier im Bsp. "main") geleitet. In die für die Ausgabe zuständige Datei "searchresults.html" muss das folgende Java-Script eingetragen werden:
zwischen <head> und </head>
<!--The matches are encoded in a query string--> <!--The query string has the following format (each entry is encoded so that it can safely be transferred through the URL) : "?"+[searchwords]+","+["y" if exact, else "n"]+["y" if HTML excluded, else "n"]+ [(match) [file name]+":"+[title]+":"+[anchor]+":"+[doc info]+":"+[match context]]+","...etc. --> <script language="JavaScript"> <!-- //This script is not especially fault tolerant. //If you improve on this script, please send the source code //to gilbertnews@hotmail.com so I can see what you've done. function writeResults() {
var estr=this.location.toString();
var index=estr.indexOf("?");
if(index==-1) {
document.writeln("<h1>No search results were provided</h1>");
return;
}
index++;
estr=estr.substring(index,estr.length);
index=estr.indexOf(",");
document.writeln("<dl>");
document.write("<dt>Your search for <b>"+unescape(estr.substring(0,index))+"</b> ");
estr=estr.substring(index+1,estr.length);
if(estr.substring(0,1)=="y") document.write(" (with exact matches only) ");
if(estr.substring(1,2)=="y") document.write(" (excluding HTML) ");
document.writeln("yielded:<p>");
estr=estr.substring(2,estr.length);
index=-1;
var lastindex=0;//colon
var clastindex=0;//comma
var currdata="";
var myurl="";
var myanchor="";
var colonindex=-1;
var info="";
var context="";
var anchor="";
while((index=estr.indexOf(",",index+1))!=-1) {
currdata=estr.substring(clastindex,index);
clastindex=index+1;
colonindex=currdata.indexOf(":");
if(colonindex!=-1) {
//Get the URL
myurl=unescape(currdata.substring(0,colonindex));
//Get the page's title
lastindex=colonindex+1;
colonindex=currdata.indexOf(":",lastindex);
document.write("<dd><a href=\""+myurl+"\"><b>"+ unescape(currdata.substring(lastindex,colonindex))+"</b> <b>("+myurl+")</b></a>");
//Get the anchor
anchor=unescape(currdata.substring(lastindex,colonindex));
if(anchor.length>0) document.write(" <a href=\""+myurl+"#"+anchor+"\">[Closest anchor]</a>");
document.writeln("<br>");
info=unescape(currdata.substring(lastindex,colonindex));
document.write("<font size=2>");
if(info.length>0) document.write("<b>Document Info</b>: "+info+" ");
context=unescape(currdata.substring(lastindex,currdata.length));
if(context.length) document.writeln("<b>Match Context</b>: \""+context+"\"<p>");
document.write("</font>");
document.writeln("</dl>"); } //--> </script>
zwischen <body> und </body>
<script language="JavaScript"> <!--
writeResults(); //--> </script> <noscript> This feature requires both JavaScript. </noscript>
Eine detaillierte Beschreibung der Parameter sowie ein lauffähiges Beispiel befinden sich im ZIP-File.
The Gilbert Post