PDA

View Full Version : Getting start and end DOM nodes from a selection in IE.


drylight
03-19-2008, 08:28 AM
Hi all,

Using IE, if I highlight some HTML, is it possible to get the DOM nodes (elements) that are located at the start and at the end of the selection respectively?

For example; let say I have three paragraph tags:

<p id="1"> text here and there
...
</p>
<p id="2"> in the middle of things.
...
</p>
<p id="3"> finally a bit more text
...
</p>

If I then highlight from the word "and" in the first P tag, all the way up to the i in "bit" in the last paragraph, how can I get the elements P with id="1" and P with id="3"? And do this in any such scenario.

Any help would be greatly appreciated.

Cheers,
Diego