02. marts 2001 - 15:29
Der er
10 kommentarer og 1 løsning
søgerobot
Kan man lave en søge robot som KUN søger på ens ejet websted, og IKKE bruger noget sever basseret noget som fx fronpage laver ? Hvis men kan hvad skal der så til
Annonceindlæg fra Lector
02. marts 2001 - 15:31
#1
Du kan prøve med den her: <body><script language=\"JavaScript\"> var NS4 = (document.layers); // Which browser? var IE4 = (document.all); var win = window; // window to search. var n = 0; function findInPage(str) { var txt, i, found; if (str == \"\") return false; // Find next occurance of the given string on the page, wrap around to the // start of the page if necessary. if (NS4) { // Look for match starting at the current point. If not found, rewind // back to the first match. if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; // If not found in either direction, give message. if (n == 0) alert(\"Not found.\"); } if (IE4) { txt = win.document.body.createTextRange(); // Find the nth match from the top of the page. for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart(\"character\", 1); txt.moveEnd(\"textedit\"); } // If found, mark it and scroll it into view. if (found) { txt.moveStart(\"character\", -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } // Otherwise, start over at the top of the page and find first match. else { if (n > 0) { n = 0; findInPage(str); } // Not found anywhere, give message. else alert(\"Not found.\"); } } return false; } </script> <form name=\"search\" onSubmit=\"return findInPage(this.string.value);\"> <font size=3><input name=\"string\" type=\"text\" size=15 onChange=\"n = 0;\"></font> <input type=\"submit\" value=\"Find\"> </form></body>
02. marts 2001 - 17:45
#8
Denne skulle nu kunne, men kræver en del skrive/kopi arbejde. <head> <SCRIPT LANGUAGE=\"JavaScript\"> var item = new Array(); c=0; item[c]=new Array(\"index.html\",\"\",\"DemoSite\",\"index,main,start,home,front\",\"Beskrivelse\"); c++; item[c]=new Array(\"about.htm\",\"\",\"About Me\",\"about,author,contact,email,who\",\"Beskrivelse\"); c++; item[c]=new Array(\"links.htm\",\"\",\"Links page\",\"links,more,where,similar,friends\",\"Beskrivelse\"); c++; item[c]=new Array(\"main.htm\",\"main/\",\"Main Page\",\"content,main,focus\",\"Beskrivelse\"); page=\"<html><head><title>Search Results</title></head><body bgcolor=\'white\'><center><table border=0 cellspacing=10 width=80%>\"; function search(frm) { win = window.open(\"\",\"\",\"scrollbars\"); win.document.write(page); txt = frm.srchval.value.split(\" \"); fnd = new Array(); total=0; for (i = 0; i < item.length; i++) { fnd[i] = 0; order = new Array(0, 4, 2, 3); for (j = 0; j < order.length; j++) for (k = 0; k < txt.length; k++) if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != \"\") fnd[i] += (j+1); } for (i = 0; i < fnd.length; i++) { n = 0; w = -1; for (j = 0;j < fnd.length; j++) if (fnd[j] > n) { n = fnd[j]; w = j; }; if (w > -1) total += show(w, win, n); fnd[w] = 0; } win.document.write(\"</table><br>Total found: \"+total+\"<br></body></html>\"); win.document.close(); } function show(which,wind,num) { link = item[which][1] + item[which][0]; line = \"<tr><td><a href=\'\"+link+\"\'>\"+item[which][2]+\"</a> Score: \"+num+\"<br>\"; line += item[which][4] + \"<br>\"+link+\"</td></tr>\"; wind.document.write(line); return 1; } // End --> </script> </HEAD> <BODY> <center> <form method=get action=\"java script:void(0)\" onsubmit=\"search(this); return false;\"> <tr><td><input type=text name=srchval value=\"\"><input type=submit value=\"Search\"></td></tr> </form> </center>