html的 findText方法如何向后搜索(backwards),马上结帖!!

Javatomchen 2005-07-05 10:47:30
向前搜索没有问题
...全文
130 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2005-07-06
  • 打赏
  • 举报
回复
<body>
<table>
<tr>
<td >fffffffffffffffffffffffffffffffffffffffffffffftfffffffffffff</td>
</tr>
</table>
<input value="点击此就可以向后查找F" onclick=myfindtext("f") type=button unselectable=true>
<script language ='javascript'>
<!--

var rng = document.body.createTextRange();
function myfindtext(text){
rng.collapse(false);
if(rng.findText(text,-1,1)){
rng.select();
rng.collapse(true);
}else{
alert("end");
}
}
//-->
</script>
qidizi 2005-07-06
  • 打赏
  • 举报
回复
<html>
<head>
<title>无标题</title>
<head>
<body>
<table>
<tr>
<td style="background-image: url(http://community.csdn.net/Images/ad/120-60_050526.gif)">fffffffffffffffffffffffffffffffffffffffffffffftfffffffffffff</td>
</tr>
</table>点击此就可以向后查找F
<input value=f onclick=myfindtext(this.value)>
<script language ='javascript'>
<!--

var rng = document.body.createTextRange();
function myfindtext(text){
rng.collapse(false);
if(rng.findText(text,10000000000,1)){
rng.select();
rng.collapse(true);
}else{
alert("end");
}
}
//-->
</script>

</body>
</html>
Javatomchen 2005-07-06
  • 打赏
  • 举报
回复
哪位有demo?
Javatomchen 2005-07-06
  • 打赏
  • 举报
回复
多谢二位
Javatomchen 2005-07-05
  • 打赏
  • 举报
回复
文档我看了还是没搞定,有没有示例?
孟子E章 2005-07-05
  • 打赏
  • 举报
回复
A positive integer indicates a forward search; a negative integer indicates a backward search.


bFound = TextRange.findText(sText [, iSearchScope] [, iFlags])
Parameters

sText Required. String that specifies the text to find.
iSearchScope Optional. Integer that specifies the number of characters to search from the starting point of the range. A positive integer indicates a forward search; a negative integer indicates a backward search.
iFlags Optional. Integer that specifies one or more of the following flags to indicate the type of search: 0 Default. Match partial words.
1 Match backwards.
2 Match whole words only.
4 Match case.
131072 Match bytes.
536870912 Match diacritical marks.
1073741824 Match Kashida character.
2147483648 Match AlefHamza character.

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧