开发者

using Range.StartContainer in ContentWindow

what is the result that this instruction using xpcom

  Sel:=ContentWindow.GetSelection;
  Range:=Sel.GetRangeAt(0开发者_StackOverflow中文版);     
  Range.StartContainer

GetSelection gives us all the items selected?


A selection consists of a number of Range objects, usually 1. Each Range objects consists of a StartContainer and StartOffset, and an EndContainer and EndOffset. If the appropriate container is a text node, then the offset is a character offset, but sometimes the container is an element, in which case the offset is a child node index. So for instance, given the HTML

<p>The <strong>strong</strong> tag usually results in <b>bold</b> text.</p>

If the start container is the text "strong" and the start offset is 3, while the end container is the text "bold" and the end offset is 2, then the selected text is "ong tag usually results in bo".

After making allowances for the special cases (such as the start and end containers being the same text node) you can use methods such as a TreeWalker to visit the nodes in the range.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜