求兼容firefox和ie的一段类似ctrl+f功能的js代码?!
来源:百度知道 编辑:UC知道 时间:2024/05/22 05:36:35
<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)
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)
您好,感谢您对火狐的支持
给您提供一个示例,请参考:http://www.codesky.net/article/201004/97185.html,兼容火狐和IE等浏览器。
您可以在火狐官方网站下载火狐浏览器,在火狐社区了解更多内容。希望我的回答对您有所帮助,如有疑问,欢迎继续在本平台咨询。