W3C DOM Compatibility - Range

Last update 11 May 2007.

This page has been translated into Romanian.

This table is under construction. I haven't yet created test pages, and for most methods and properties I only tested basic support: does the browser throw an error when you use the method or property, or not?

Note that the collapse() method occurs in all three models, but means something different in all three. Details forthcoming.

See the Introduction to Ranges for a general overview.

These tables detail support for handling user selections in all modern browsers. Unfortunately there are three important modules: W3C Range, Mozilla Selection, and Microsoft TextRange.

W3C Range

Method or property Explorer 6/7 Firefox 2 Safari 1.3 Opera 9
cloneContents()

Test page
No Yes Incomplete Yes
docFrag = rangeObject.cloneContents()
The contents of the Range object are cloned and added to a document fragment, which is returned.

Safari problem: if the range is empty, null is returned instead of an empty documentFragment. Possible solution:

docFrag = rangeObject.cloneContents() || document.createDocumentFragment()
cloneRange()

Test page
No Yes Yes Yes
Notes
collapse()

Test page
TBD TBD TBD TBD
Notes
collapsed

Test page
No Yes Yes Yes
Notes
commonAncestorContainer

Test page
No Yes Yes Yes
Notes
compareBoundaryPoints()

Test page
No Yes Yes Yes
Notes
comparePoint()
Mozilla extension
Test page
No Yes No No
Notes
createContextualFragment()
Mozilla extension
Test page
No Yes Yes Yes
Notes
deleteContents()

Test page
No Yes Yes Yes
Deletes the contents of the Range permanently. No return value
detach()

Test page
No Yes Yes Yes
Notes
endContainer

Test page
No Yes Yes Yes
The node that contains the end point of the user selection. Usually a text node.
endOffset

Test page
No Yes Yes Incomplete
Opera returns 0 if the selection is empty.
extractContents()

Test page
No Yes Yes Yes
docFrag = rangeObject.extractContents()
Cuts the Range object from the DOM tree and returns it as a document fragment. This fragment can be pasted into the page.
insertNode()

Test page
No Yes Yes Yes
Notes
isPointInRange()
Mozilla extension
Test page
No Yes No No
Notes
selectNode()

Test page
No Yes Yes Yes
Notes
selectNodeContents()

Test page
No Yes Yes Yes
Notes
setEnd()

Test page
No Yes Yes Yes
Notes
setEndAfter()

Test page
No Yes Yes Yes
Notes
setEndBefore()

Test page
No Yes Yes Yes
Notes
setStart()

Test page
No Yes Yes Yes
Notes
setStartAfter()

Test page
No Yes Yes Yes
Notes
setStartBefore()

Test page
No Yes Yes Yes
Notes
startContainer

Test page
No Yes Yes Yes
The node that contains the starting point of the user selection. Usually a text node.
startOffset

Test page
No Yes Yes Incomplete
Opera returns 0 if the selection is empty.
surroundContents()

Test page
No Yes Yes Yes
Notes

Mozilla Selection

Method or property Explorer 6/7 Firefox 2 Safari 1.3 Opera 9
addRange()

Test page
No Yes No Yes
Notes
anchorNode

Test page
No Yes Yes Yes
userSelection.anchorNode
The node that contains the starting point of the user selection. Usually a text node.
anchorOffset

Test page
No Yes Yes Incomplete
Opera returns 0 if the selection is empty.
collapse()

Test page
TBD TBD TBD TBD
Notes
collapseToEnd()

Test page
No Yes Yes Yes
Notes
collapseToStart()

Test page
No Yes Yes Yes
Notes
containsNode()

Test page
No Yes No Yes
Notes
deleteFromDocument()

Test page
No Yes No Yes
Notes
extend()

Test page
No Yes No Yes
Notes
focusNode

Test page
No Yes Yes Yes
userSelection.focusNode
The node that contains the end point of the user selection. Usually a text node.
focusOffset

Test page
No Yes Yes Incomplete
Opera returns 0 if the selection is empty.
getRangeAt()

Test page
No Yes No Yes
rangeObject = userSelection.getRangeAt(0)
Converts a Mozilla Selection to a W3C Range.
isCollapsed

Test page
No Yes Yes Yes
Notes
rangeCount

Test page
No Yes No Yes
Notes
removeAllRanges()

Test page
No Yes No Yes
Notes
removeRange()

Test page
No Yes No Yes
Notes
selectAllChildren()

Test page
No Yes No Yes
Notes
selectionLanguageChange()

Test page
No Yes No Yes
Notes

Microsoft TextRange

Method or property Explorer 6/7 Firefox 2 Safari 1.3 Opera 9
boundingHeight

Test page
Yes No No No
Notes
boundingLeft

Test page
Yes No No No
Notes
boundingTop

Test page
Yes No No No
Notes
boundingWidth

Test page
Yes No No No
Notes
collapse()

Test page
TBD TBD TBD TBD
Notes
compareEndPoints()

Test page
Yes No No No
Notes
duplicate()

Test page
Yes No No Yes
Notes
expand()

Test page
Yes No No No
Notes
findText()

Test page
Yes No No No
Notes
htmlText

Test page
Yes No No No
htmlString = userSelection.htmlText
Returns the HTML content of the TextRange as a string. Equivalent to innerHTML.
Read only.
move()

Test page
Yes No No Yes
Notes
moveEnd()

Test page
Yes No No Yes
Notes
moveStart()

Test page
Yes No No Yes
Notes
moveToElementText()

Test page
Yes No No Yes
Notes
moveToPoint()

Test page
Yes No No No
Notes
offsetLeft

Test page
Yes No No No
Notes
offsetTop

Test page
Yes No No No
Notes
parentElement()

Test page
Yes No No Yes
Notes
pasteHTML()

Test page
Yes No No No
When pasting HTML into a text node, the text node is automatically split.
scrollIntoView()

Test page
Yes No No No
Notes
select()

Test page
Yes No No Yes
Notes
text

Test page
Yes No No Yes
string = userSelection.text
Returns the text of the TextRange as a string. Equivalent to innerText.
Read/write.