Inserts an element into the document hierarchy as a child node of a parent object.
HRESULT insertBefore( IHTMLDOMNode *newChild, VARIANT refChild, IHTMLDOMNode **node );
- [in] Pointer to an IHTMLDOMNode that specifies the new object to be inserted.
- [in] VARIANT of type VT_DISPATCH or VT_UNKNOWN that specifies the placement of the new element. If this parameter is specified, the new element will be inserted immediately before this existing child element.
- [out, retval] Address of a pointer that returns a reference to the element that is inserted into the document.
Returns one of the following values.
S_OK The operation completed successfully. W3CException_DOM_VALIDATION_ERR The operation would cause the node to fail validation. W3CException_DOM_HIERARCHY_REQUEST_ERR The node cannot be inserted at the requested location. W3CException_DOM_WRONG_DOCUMENT_ERR The node is owned by a different document and cannot be used. W3CException_DOM_NO_MODIFICATION_ALLOWED_ERR An attempt is made to modify an object that cannot be changed. W3CException_DOM_NOT_FOUND_ERR The specified node cannot be found. W3CException_DOM_NOT_SUPPORTED_ERR The requested operation is not supported.
Do not specify the refChild parameter when inserting the first child node. If children already exist and you do not specify the refChild parameter, the newChild becomes the last child of the parent object.
This method is accessible at run time. If elements are removed at run time, before the closing tag has been parsed, areas of the document might not render.
Internet Explorer 9. Exceptions are only supported when webpages are displayed in IE9 Standards mode.
Microsoft Internet Explorer 6 and later. The attribute object supports this method.