主要是没有搞清楚movestart和moveend光标是如何移动的,
请帮忙解释下啦,谢谢

解决方案 »

  1.   

    moveEnd:更改范围的结束位置。
    iMoved = TextRange.moveEnd(sUnit [, iCount])sUnit:
    Required. String that specifies the units to move, using one of the following values:
    //必需参数,字符串格式,指定移动的单位,用下面4种中的一种
     
    1.character
    Moves one or more characters. 
    2.word
    Moves one or more words. A word is a collection of characters terminated by a space or some other white-space character, such as a tab. 
    3.sentence
    Moves one or more sentences. A sentence is a collection of words terminated by a punctuation character, such as a period. 
    4.textedit
    Moves to the start or end of the original range. 
    iCount:
    Optional. Integer that specifies the number of units to move. This can be positive or negative. The default is 1. 
    //可选参数, 整型格式,指定移动的个数,可以是正整数,可以是负整数,默认值为一iMoved:如果操作成功,返回iCount,失败则返回0
      

  2.   

    for (i = 0; i <= n && (found =txt.findText(str) ) != false; i++)
    ========>
    for (i = 0;i <= n&& (txt.text==txt.findText(str))!=false; i++)
      

  3.   

    不是上面的原因,赏花你测试一下就明白我的意思了,其实就是start和end起始位置的问题,
    搞不明白
      

  4.   

    我不清楚IE4什么语法
    下面代码IE6测试通过:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>new page</title>
    </head>
    <body>
    casdfasfda
    </body>
    <script>
    txt = document.body.createTextRange();
    var str="a";
    var n=txt.text.length;
    for(i = 0; i <= n && (txt.text ==txt.findText(str) ) != false; i++) {
    txt.moveStart("character", 3);
    txt.moveEnd("character",1);
    txt.moveEnd("textedit");//请问这个是什么意思???
    }
    alert(txt.text);//a
    </script>
    </html>