要实现页面内查找可以这样<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
{
alert(str + "---您要找的文字不存在。\n \n请试着输入页面中的关键字再次查找!");
}
}
return false;
}function find_str()
{
if (document.all.find_content.value=="")
{
alert("请先输入你要查找的内容");
}
else
{
findInPage(document.all.find_content.value);
}
}</script>input type="button" name="Submit2" value="返回首页" onclick="location.href='../../'"></td>
<td width="590" align="right">内容太多看花眼了?在这儿搜索你想要的内容:
<input type="text" id="find_content">
<input type="button" name="Submit" value="搜索" onClick="find_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
{
alert(str + "---您要找的文字不存在。\n \n请试着输入页面中的关键字再次查找!");
}
}
return false;
}function find_str()
{
if (document.all.find_content.value=="")
{
alert("请先输入你要查找的内容");
}
else
{
findInPage(document.all.find_content.value);
}
}</script>input type="button" name="Submit2" value="返回首页" onclick="location.href='../../'"></td>
<td width="590" align="right">内容太多看花眼了?在这儿搜索你想要的内容:
<input type="text" id="find_content">
<input type="button" name="Submit" value="搜索" onClick="find_str()">
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货