域名注册
|
虚拟主机
|
数据库
|
设为主页
|
加入收藏
|
天诚搜索
|
RSS
网站套餐
Package
基础特惠型网站
企业标准型网站
企业大户型网站
商务政务型网站
功能单项报价表
最新推荐
Recommended
4年网络创业经历
Dreamweaver表格经验谈
61.183.41.123数据重新上传通…
局域网arp病毒
用途相似的标签
CSS网页标准制作关于网页表单…
中国互联网13年大事记
ECSHOP 显示指定分类下的文章…
您现在的位置:
天诚世纪
>>
技术中心
>>
网页特效
>>
其它特效
>> 正文
查找页面中的字符
作者:
天诚世纪
更新时间:2009-6-16 11:22:23
来源:
天诚世纪
以下是HTML网页特效代码,点击运行按钮可查看效果:
<html> <head> <title>网页特效|tc-21.com|---查找页面中的字符</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <body bgcolor="#FFFFFF"> <table bgcolor="#000000" cellspacing="1" width="500" align="center"> <tbody> <tr> <td bgcolor="#4775c3" align="center"><strong style="font-weight: 400"> <font color="#FFFFFF" face="宋体" style="font-size: 9pt">查找页面中的字符</font></strong></td> </tr> </tbody> </table> <table border="0" cellpadding="0" cellspacing="0" width="500" align="center"> <tr> <td align="left" valign="top" width="340"></td> <td align="left" valign="top" width="109"> <p align="center"></p> </td> <td align="left" valign="top" width="304"><font face="宋体" size="4" color="#FF0000"> </font></td> </tr> <tr> <td align="left" width="340" valign="top"><font face="宋体" color="#FF0000"> <span style="font-size: 9pt">在页面中实现搜索功能,类似Word等文本编辑软件里的搜索功能,只要是页面中的字符(别管是显在的还是隐蔽在文本框内部的),用这个都能找出来,从此,你的网页中又多了一个强大的不同寻常的工具。</span></font></td> <td align="left" width="109" valign="top"><font face="宋体" color="#FF0000"> </font></td> <td align="left" valign="top" width="304"> <span style="font-size: 9pt">你可以输入“脚本”一词查查看(共有三处)<br> <script language="JavaScript"> var NS4 = (document.layers); // Which browser? var IE4 = (document.all); var win = window; // window to search. var n = 0; function findInPage(str) { var txt, i, found; if (str == "") return false; // Find next occurance of the given string on the page, wrap around to the // start of the page if necessary. if (NS4) { // Look for match starting at the current point. If not found, rewind // back to the first match. if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; // If not found in either direction, give message. if (n == 0) alert("Not found."); } if (IE4) { txt = win.document.body.createTextRange(); // Find the nth match from the top of the page. for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit"); } // If found, mark it and scroll it into view. if (found) { txt.moveStart("character", -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } // Otherwise, start over at the top of the page and find first match. else { if (n > 0) { n = 0; findInPage(str); } // Not found anywhere, give message. else alert("Not found."); } } return false; } </script> </span> <form name="search" onSubmit="return findInPage(this.string.value);"> <p align="center"> <font size="3"><input name="string" type="text" size="15" onChange="n = 0;"></font> <input type="submit" value="Find"> </p> </form> </td> </tr> </table> <div align="center"> <table width="500"> <tbody> <td width="492"> <div align="center"> <center> <table width="100%"> <tr> <td bgcolor="#3366CC" style="BORDER-BOTTOM: #817af3 1px solid; BORDER-LEFT-COLOR: #817af3; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-COLOR: #817af3; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-COLOR: #817af3; BORDER-TOP-WIDTH: 1px" align="center"><font color="#FFFFFF" style="font-size: 9pt">使用说明</font></td> </tr> <tr bgcolor="#ffffff"> <td bgcolor="#FFFFFF" style="BORDER-BOTTOM: #817af3 1px solid; BORDER-LEFT-COLOR: #817af3; BORDER-LEFT-WIDTH: 1px; BORDER-RIGHT-COLOR: #817af3; BORDER-RIGHT-WIDTH: 1px; BORDER-TOP-COLOR: #817af3; BORDER-TOP-WIDTH: 1px" align="center"><br> <span style="font-size: 9pt">制作步骤:请将下面的代码插入到<body>部分: <br> </span> <form name="step"> <a href="javascript:selectAll('step.stepone')"><p></a><br> <textarea name="stepone" rows="12" cols="60">你可以输入“脚本”一词查查看 <script language="JavaScript"> var NS4 = (document.layers); // Which browser? var IE4 = (document.all); var win = window; // window to search. var n = 0; function findInPage(str) { var txt, i, found; if (str == "") return false; // Find next occurance of the given string on the page, wrap around to the // start of the page if necessary. if (NS4) { // Look for match starting at the current point. If not found, rewind // back to the first match. if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; // If not found in either direction, give message. if (n == 0) alert("Not found."); } if (IE4) { txt = win.document.body.createTextRange(); // Find the nth match from the top of the page. for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit"); } // If found, mark it and scroll it into view. if (found) { txt.moveStart("character", -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } // Otherwise, start over at the top of the page and find first match. else { if (n > 0) { n = 0; findInPage(str); } // Not found anywhere, give message. else alert("Not found."); } } return false; } </script> <form name="search" onSubmit="return findInPage(this.string.value);"> <font size=3><input name="string" type="text" size=15 onChange="n = 0;"></font> <input type="submit" value="Find"> </form> 哈哈,这里还有一个“脚本”</textarea> </p> </form> </td> </tr> <tr bgcolor="#ffffff"> <td bgcolor="#3366CC"></td> </tr> </table> </center> </div> <script language="Javascript"> <!-- function selectAll(theField){ var tempval=eval("document."+theField) tempval.focus() tempval.select() } //--> </script> </table> </body>
.
[提示:可先修改代码再按运行]
本文链接:http://www.tc-21.com/ITCenter/200906/20090616112223.html
上一篇文章:
测试你的镜像站的速度
下一篇文章:
站内搜索脚本(一)
更多关于
其它特效
的新闻
相关文章
更方便的单选框
站内搜索脚本(二)
FTP页面登录
有检测功能的表单递交脚本
E-mail形式的密码登录窗口
用密码保护页面
进入页面弹出收藏夹提示
站内搜索脚本(三)
::::::
网页模板
|
建站指导
|
视频教程
|
图片中心
|
在线咨询
|
网站运营
|
网站推广
|
图片素材
::::::
CopyRight 2007 All Rights Reserved 天诚世纪 版权所有
鄂ICP备12000046号
联系电话:18995527083 18995527081 QQ:448163207 32301667 Email:my_tc@126.com
::::::搜索关键字:
武汉网站制作
|
武汉做网站
|
武汉网站建设
|
武汉网页制作
|
天诚世纪
|
武汉网页制作公司
|
网页模板
|::::::