insertAdjacentElement method

Inserts an element at the specified location.


IHTMLElement retVal = object.insertAdjacentElement(where, insertedElement);


where [in]

Type: BSTR

A BSTR that specifies where to insert the HTML element, using one of the following values.


Inserts insertedElement immediately before the object.


Inserts insertedElement after the start of the object, but before all other content in the object.


Inserts insertedElement immediately before the end of the object, but after all other content in the object.


Inserts insertedElement immediately after the end of the object.

insertedElement [in]

Type: [IHTMLElement](aa752279(v=vs.85).md)

A pointer to an IHTMLElement2 that specifies the element to be inserted adjacent to the object that invoked the IHTMLElement2::insertAdjacentElement method.

Standards information

There are no standards that apply here.


You cannot insert text while the document is loading. Wait for the onload event before attempting to call this method.

If you try to insert an object that already exists on the page, the existing object is moved to the point that you specified in the IHTMLElement2::insertAdjacentElement method; no new object is created.