I am net_lover,If you wanna email to net_lover,you can send a mail to him!
I am net_lover,If you wanna email to net_lover,you can send a mail to him!<FORM name="search">
要查找的字符:<INPUT onchange="n = 0;" size=15 name="string" value="net_lover">
替换成:<INPUT name="rpl" value="【孟子E章】"></FORM>
<SCRIPT language=JavaScript>
 var NS4 = (document.layers);
 var IE4 = (document.all);
 var win = window;
 var n = 0;
 function findInPage(str,bln) {
 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++) {
 if(bln==0)
 txt.moveStart("character", 1);
 else
 txt.moveStart("character", 0);
 txt.moveEnd("textedit");
 }
 if (found) {
 txt.moveStart("character", -1);
 txt.findText(str);
 if(bln==1)
 txt.pasteHTML("<font color=red>"+document.search.rpl.value + "</font>") txt.scrollIntoView();
 txt.select();
 txt.moveEnd("textedit");
 n++;
 
 findInPage(document.search.string.value,1)
 }
 else {
 if (n >0) {
 n = 0;
 findInPage(str); }
}
}
return false;
}
findInPage(document.search.string.value,1)
</SCRIPT>

解决方案 »

  1.   

    谢谢楼上这位朋友的帮忙,但是我不想通过form来实现,我的意思是不用
    findInPage(document.search.string.value,1),而直接用类似于这样的state:
    findInPage(document,1),直接在整个document里搜索,而不是在form里搜索,any suggestin is regarded!!
      

  2.   

    else {
     if (n >0) {
     n = 0;
     findInPage(str); },这里的函数findInPage()怎么只有一个参数啊!