我希望有一个搜索引擎,只能搜索到我的网站。我目前有一些JavaScript代码,但它只能搜索特定页面上的单词。如果可能的话,我需要它搜索到我的网站内部链接。
由于我的网站位于内部 Intranet 上,因此无法使用 Google 搜索引擎。
<SCRIPT language=JavaScript>
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert("Not found.");
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert("Sorry, we couldn't find.Try again");
}
}
return false;
}
</SCRIPT>
它对于搜索当前页面非常有效,但我希望有一种方法可以搜索我网站上的所有页面。
(onsubmit="return findInPage(this.string.value); 在按钮标签中。)