大侠们,有没有各种Javascript方法的使用参考说明,谢谢了先

zgczsf 2003-06-01 02:32:35
例如:FindText,MoveStart等等方法,我发现大侠们提供的"文本查找"都能往下查找,不能往上查找,所以有感而发。这种文档对于我这个菜鸟来说很重要。如果谁有,可以直接发送给我“zhou@cnb-net.com”
谢谢
...全文
104 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zgczsf 2003-06-02
  • 打赏
  • 举报
回复
根据大侠们的提示,下面为在一个TextArea中查找文字,可上下查询
var IE4 = (document.all);
var win = window;
var n = 0;

function T_Check_Changed()
{
n = 0;
}

function findInPage(str, num, type)
{
//type = 0 means find down,type = 1 means find up
var txt, i, found;

if (IE4)
{
txt = window.document.f_Journal.T_Journal.createTextRange();
for (i = 0; i <= num && (found = txt.findText(str)) != false; i++)
{
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found)
{
txt.moveStart("character", -1);
txt.findText(str);
txt.scrollIntoView();
txt.select();
txt.moveEnd("textedit");
if (type == 0)
n++;
else
n--;
return true;
}
else
{
return false;
}
}//end of IE4
}

function findInPageDown(str)
{
var ret;

if (str == "")
{
alert("検索文字はNULLです!");
return false;
}

ret = findInPage(str, n, 0);
if (ret == false)
{
n = 0;
ret = findInPage(str, n, 0);
if (ret == false)
{
alert("検索文字は見せてません!");
}
}

return true;
}


function findInPageUp(str)
{
var ret;
var txt, i, found;

if (str == "")
{
alert("検索文字はNULLです!");
return false;
}

txt = window.document.f_Journal.T_Journal.createTextRange();
if (n > 1)
{
ret = findInPage(str, n-2, 1);
}
else
{
n = 0;
for (i = 0;(found = txt.findText(str)) != false; i++)
{
txt.moveStart("character", 1);
txt.moveEnd("textedit");
n++;
}
if (n > 0)
{
txt.moveStart("character", -1);
txt.findText(str);
txt.scrollIntoView();
txt.select();
txt.moveEnd("textedit");
return true;
}
else
{
alert("検索文字は見せてません!");
}
}
return true;
}
zgczsf 2003-06-01
  • 打赏
  • 举报
回复
谢谢
但好像我没有找到关于各种方法的说明,包括参数及其含义
jshao 2003-06-01
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/942/942792.xml?temp=.1446039

87,987

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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