JavaScript's createTextRange()

Last post 06-10-2005, 8:12 PM by fcatacutan. 1 replies.
Sort Posts: Previous Next
  •  06-10-2005, 2:06 PM 7473

    JavaScript's createTextRange()

    Hi,
     
    I'm trying to utilize JavaScript such that a user clicking on an item in a ListBox will take them to a specific location in CuteEditor.  Version 2.0 of CuteEditor allowed me to use createTextRange().  However, this does not appear to work in Version 4.0.
     
    I found a previous post -- http://www.cutesoft.net/forums/1938/ShowPost.aspx -- in the forum which mentioned this issue.  But the original author of the post never replied to Adam's question.

    Below is the JavaScript that I'm using:

        var editor = document.getElementById( '<%=cedArticleText.ClientID%>' );
        var editdoc = editor.GetDocument();
        var text = editdoc.body.innerHTML;
        var exp = new RegExp( item );
        var found = exp.exec( text );

        if ( found == null )
        {
            return;
        }

        var range = editdoc.body.createTextRange();

        if ( range.findText( '[' + found[0] + ']' ) )
        {
            range.select();
            range.scrollIntoView();
        }

    I've checked the value of range[0] and determined that its value is NaN.  Any assistance would be greatly appreciated since I have very little experience with JavaScript.

    Thanks in advance,
    Fermin
  •  06-10-2005, 8:12 PM 7477 in reply to 7473

    Re: JavaScript's createTextRange()

    Please disregard.  The code that I provided earlier appears to work.
     
    Fermin
View as RSS news feed in XML