我想要一个只搜索我自己的网站的搜索引擎。我目前有一些JavaScript,但它只在特定页面上搜索单词。如果可能的话,我需要它搜索我网站中的链接。
我的网站位于内部Intranet上,因此无法使用Google搜索引擎。
< SCRIPT language = JavaScript> var NS4 =(document.layers); var IE4 =(document.all); var win = window; var n = 0; 函数findInPage(str){ var txt,i,found; if(str ==) return false; 如果(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(对不起,我们找不到了。再试一次); } } 返回false; } < / SCRIPT>
(onsubmit =return findInPage(this.string.value); )
它可以很好地搜索那个页面,但我希望有一种方法可以搜索所有页面我的网站。
解决方案几点建议:
希望这有助于!
I want to have a search engine which searches only my own site. I have some JavaScript currently, but it only searches words on that specific page. I need it to search the links within my site if possible.
I cannot use the Google search engine as my site is on an internal intranet.
<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); in the button tag.)
It works great for searching that page, but I was hoping there was a way to search all pages on my site.
解决方案Few suggestions:
Hope this helps!
更多推荐
Javascript搜索引擎(搜索自己的网站)
发布评论