JavaScript selection/range framework

隐身守侯 提交于 2019-12-31 09:04:11

问题


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.


回答1:


(Made an answer by request ;)

Take a look at IERange:

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.

Supports Range APIs:

  • 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()

Supports Selection APIs:

  • Range support (Webkit-style)
  • window.getSelection()
  • addRange(), removeAllRanges(), getRangeAt(), toString()



回答2:


I've written a new range/selection library called Rangy that is similar in concept to IERange but goes quite a lot further. The core is pretty much complete and currently available to download. I'm currently bugfixing and documenting it and it should be only be a few weeks before a full release.

UPDATE 31 August 2011

Rangy is now stable and at version 1.2 (downloads page).




回答3:


fieldselection is a very usable jquery plugin for selection/range manipulation.



来源:https://stackoverflow.com/questions/2134482/javascript-selection-range-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!