Wrox Home  
Search P2P Archive for: Go

  Return to Index  

html_code_clinic thread: Character position information in TextRange


Message #1 by "DHK" <Ultranio@h...> on Thu, 5 Oct 2000 02:17:43 +0100
Greetings from an HTML beginner...

Apologies if this has been brought up before, 
but I was wondering if there was any way
that I could get hold of the values of the first
and last character position within a TextRange object.

For example in the code below that has the TextRange
object as 'range':

    range = document.selection.createRange()

I understand that I can get the text by

    alert(range.text)

But would there be any way I can get the initial 
character position and the final character position,
perhaps assuming that the selected 'range' object is 
a single word within a paragraph. And can I get
the values by a method or property of the TextRange
object, instead of resorting to string objects?

As a dumb illustration:

 The paragraph:           <p>I like HTML.... blah blah blah...</p>
 The character position:     012345678910
    range.text= "like"
    range.WHATSTHIS??? = 2,5

I would like to know the "WHATSTHIS???" method or property
that would relay the two values (if it exists, by the way).

Thank you,

DHK



  Return to Index