页面搜索的javascript脚本
网上搜索到的页面搜索关键字的脚本大多是这个
<script language= "JavaScript ">
function findInPage(str)
{
var txt, i, found,n = 0;
if (str == " ")
{
return false;
}
txt = 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
&n