首页 »Javascript教程 » js代码:JS 页面内容搜索 类似于 Ctrl+F功能的实现代码 »正文js代码:JS 页面内容搜索 类似于 Ctrl+F功能的实现代码来源: 发布时间:星期六, 2008年12月27日 浏览:74次 评论:0
<html>
<META HTTP-EQUIV="Content-Type" content="text/html; char=gb_2312-80"> <TITLE>WinWebMail</TITLE> <script language="JavaScript"> <!-- function doZoom(size){ document.getElementById('zoom').style.fontSize=size+'px' } var DOM = (document.getElementById) ? 1 : 0; var NS4 = (document.layers) ? 1 : 0; var IE4 = 0; (document.all) { IE4 = 1; DOM = 0; } var win = window; var n = 0; function findIt { (document.getElementById("searchstr").value != "") findInPage(document.getElementById("searchstr").value); } function findInPage(str) { var txt, i, found; (str "") false; (DOM) { win.find(str, false, true); true; } (NS4) { (!win.find(str)) while(win.find(str, false, true)) n; n; (n 0) alert("未找到指定内容."); } (IE4) { txt = win.document.body.createTextRange; for (i = 0; i <= n && (found = txt.findText(str)) != false; i) { txt.moveStart("character", 1); txt.moveEnd("textedit"); } (found) { txt.moveStart("character", -1); txt.findText(str); txt.select; txt.scrollIntoView; n; } { (n > 0) { n = 0; findInPage(str); } alert("未找到指定内容."); } } false; } // --> </script> <BODY> <br> <div align="center"> <table width="90%" border="0" align="center" cellspacing="0" bgcolor="#EFF7FF" style='border:1px #8CA5B5 solid;' id="zoom"> <tr bgcolor="#DBEAF5"> <td height="50" style='border-bottom:1px #8CA5B5 solid;'> <div align="center"><font ="s" color="#104A7B"><b>帮 助</b></div> <div align="center"> <table width="98%"><tr><td align="left"> <input type="text" id="searchstr" name="searchstr" ="textbox" size="10"> <input type="button" value="页内查找" _disibledevent="#FF3333">退出电子邮箱</font><br> <br> 请不要以直接关闭浏览器思路方法退出邮箱, 建议使用点击"退出"方式, 然后再关闭所有浏览器, 这样将可确保您信箱安全.<br> <br> </td> </tr> </table> </div> <br><br> </BODY> </html> 0
相关文章读者评论发表评论 |