JavaScript 选择/范围框架

2022-01-24 00:00:00 selection range dom javascript

我一直在使用选择/范围对象,因为对于特定的选择/范围内容(甚至超过 DOM),浏览器之间存在大量不一致的情况,我想知道是否有一个框架可以帮助我获得通过他们.

I've been working with selection/range objects, and because to the incredible amount of inconsistencies between browsers for specific selection/range stuff (even more than the DOM) I was wondering if there was a framework that would help me get through them.

推荐答案

(按要求回答;)

看看IERange:

IERange 功能齐全W3C DOM Ranges 的实现Internet Explorer,允许用户编写一个跨浏览器版本的他们的范围操作代码.

IERange is a feature-complete implementation of W3C DOM Ranges for Internet Explorer, allowing users to write one cross-browser version of their range manipulation code.

支持范围 API:

  • document.createRange()
  • startContainer, startOffset, endContainer, endOffset, commonAncestorContainer, 折叠
  • setStart()setEnd()setStartBefore()setStartAfter()setEndBefore(), setEndAfter(), selectNode(), selectNodeContents(), collapse()
  • insertNode(), surroundContents()
  • extractContents()cloneContents()deleteContents()
  • compareBoundaryPoints()cloneRange()createContextualFragment()toString()
  • document.createRange()
  • startContainer, startOffset, endContainer, endOffset, commonAncestorContainer, collapsed
  • setStart(), setEnd(), setStartBefore(), setStartAfter(), setEndBefore(), setEndAfter(), selectNode(), selectNodeContents(), collapse()
  • insertNode(), surroundContents()
  • extractContents(), cloneContents(), deleteContents()
  • compareBoundaryPoints(), cloneRange(), createContextualFragment(), toString()

支持选择 API:

  • 范围支持(Webkit 样式)
  • window.getSelection()
  • addRange()removeAllRanges()getRangeAt()toString()

相关文章