insertAdjacentElement method

Inserts an element at the specified location.

Syntax

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

Parameters

where [in]

Type: BSTR

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

beforeBegin

Inserts insertedElement immediately before the object.

afterBegin

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

beforeEnd

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

afterEnd

Inserts insertedElement immediately after the end of the object.

insertedElement [in]

Type: IHTMLElement

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.

Remarks

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.