zoukankan      html  css  js  c++  java
  • about selection and range

    The fundamental difference is that a Selection represents the user's selection, while Rangerepresents a continuous part of a document independently of any visual representation. ASelection can (almost) be expressed in terms of zero, one or more Ranges but Ranges can also be created and modified completely independently of the selection.

    There is some overlap in functionality: for example, Selection's deleteFromDocument() is equivalent to calling deleteContents() on all of its component Ranges, and you can get the boundaries of the most recently selected Range in the selection using the anchorNode,anchorOffsetfocusNode and focusOffset properties. However, there are some crucial differences:

    • Selection may contain multiple Ranges. However, the only major browser to support this currently is Firefox.
    • Selection may be "backwards", by which I mean that the end boundary of the selection (represented by focusNode and focusOffset) may occur earlier in the document than the start boundary (anchorNode and anchorOffset). A Range has no direction.
    • toString() works differently. In most browsers (although notably not IE 9), calling toString() on a Selection object returns only the visible text that is selected, while calling toString() on a Range will return a concatenation of all text nodes within the range, including those within <script>elements and elements hidden via CSS.
  • 相关阅读:
    Hibernate 缓存机制
    Java 对象的串行化(Serialization)
    Java HashMap的死循环
    大牛给计算机专业学生的 7 个建议
    手机的未来
    Java虚拟机类加载机制
    JAVA中的数组是对象吗?
    JAVA中toString方法的作用
    探索哪个进程使磁盘I/O升高
    Linux运维之如何查看目录被哪些进程所占用,lsof命令、fuser命令
  • 原文地址:https://www.cnblogs.com/argb/p/2279391.html
Copyright © 2011-2022 走看看