a.htm
请强大的功能请自己增加
==============================
<iframe name=mxh src="b.htm"></iframe>
<FORM name=search onsubmit="return findInPage(this.string.value);">
要查找的字符:<INPUT onchange="n = 0;" size=15 name=string value="mxh">
替换成:<INPUT name=rpl value="net_lover">
<INPUT type=submit value=页内搜索...></FORM>
<SCRIPT language=JavaScript>
var NS4 = (document.layers);
var IE4 = (document.all);
var win = document.frames("mxh");
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", 0);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.text=document.search.rpl.value
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n >0) {
n = 0;
findInPage(str);
}
}
}
return false;
}
</SCRIPT>
b.htm
=====================
mxh_mxhok!
请强大的功能请自己增加
==============================
<iframe name=mxh src="b.htm"></iframe>
<FORM name=search onsubmit="return findInPage(this.string.value);">
要查找的字符:<INPUT onchange="n = 0;" size=15 name=string value="mxh">
替换成:<INPUT name=rpl value="net_lover">
<INPUT type=submit value=页内搜索...></FORM>
<SCRIPT language=JavaScript>
var NS4 = (document.layers);
var IE4 = (document.all);
var win = document.frames("mxh");
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", 0);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.text=document.search.rpl.value
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n >0) {
n = 0;
findInPage(str);
}
}
}
return false;
}
</SCRIPT>
b.htm
=====================
mxh_mxhok!
{
RpAll = dialogArguments.HtmlEditor.document.selection.createRange();
RpAll.moveStart("character", 1);
}
function FindIt(str, replacestr, newstr)
{if(str=="")
{alert("输入么查询的字符!");
document.find.findwhat.focus();
return;
}txt = dialogArguments.HtmlEditor.document.selection.createRange();txt.collapse(false);
txt.moveEnd("textedit");
found = txt.findText(str);
if(found) {txt.moveStart("character", -1);
txt.findText(str);if(replacestr)
txt.text=newstr;
txt.select();
txt.scrollIntoView();}
else
{
window.alert("查询结束,没有你所要的字符!");
}}
就是当查找的时候,查找到了的时候,替换一下,再高亮显示下一个需要替换的字符(象WORD的查找替换一样)