Creating TextRange from dom node's inner content


D

dino @ wrk

is there a smooth way how to create an MS TextRange object which would
contain only inner content of some
DOM node?

let's say i have a node looking like this...
<div id="myDiv">some text <b>inside</b> div element</div>

....and would like to create a range/textrange which would contain only:
"some text <b>inside</b> div element"


solving this using w3c implementation is rather easy, in which case range
will only span over innerHTML of myDiv:

var range = document.createRange();
range.selectNodeContents(reference_to_myDiv);


however, i'm not able to find the suitable solution for ms/ie
implementation... msdn isn't really helpful either, since the only thing
similar to abovewritten would be using method moveToElementText() of
TextRange object, which again unfortunately returns the range spanned over
whole html of myDiv node, not just the innerHTML.


any suggestions?
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top