ZVON > References > DOM2 Reference

surroundContents (method )

Owning interface and usage:  
Range.surroundContents(newParent)

Member of these other interfaces:  
none

Description:  
Reparents the contents of the Range to the given node and inserts the node at the position of the start of the Range.

Parameters:  
Node newParent  -  The node to surround the contents with.

Returns:  
nothing

Exceptions:  
DOMException NO_MODIFICATION_ALLOWED_ERR
Raised if an [ancestor container] of either boundary-point of the Range is read-only.
DOMException WRONG_DOCUMENT_ERR
Raised if newParent and the [container] of the start of the Range were not created from the same document.
DOMException HIERARCHY_REQUEST_ERR
Raised if the [container] of the start of the Range is of a type that does not allow children of the type of newParent or if newParent is an ancestor of the [container] or if node would end up with a child node of a type not allowed by the type of node.
DOMException INVALID_STATE_ERR
Raised if detach() has already been invoked on this object.
RangeException BAD_BOUNDARYPOINTS_ERR
Raised if the Range [partially selects] a non-text node.
RangeException INVALID_NODE_TYPE_ERR
Raised if node is an Attr, Entity, DocumentType, Notation, Document, or DocumentFragment node.