Share via


insertAdjacentHTML method

[This documentation is preliminary and is subject to change.]

Inserts the given HTML text into the element at the location.

Syntax

HRESULT retVal = object.insertAdjacentHTML(where, html);

Standards information

There are no standards that apply here.

Parameters

where [in]

Type: BSTR

BSTR that specifies where to insert the HTML text, using one of the following values:

beforeBegin

Inserts html immediately before the object.

afterBegin

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

beforeEnd

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

afterEnd

Inserts html immediately after the end of the object.

html [in]

Type: BSTR

BSTR that specifies the HTML text to insert. The string can be a combination of text and HTML tags. This must be well-formed, valid HTML or this method will fail.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

If the text contains HTML tags, the method parses and formats the text as it is inserted.

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

When using the IHTMLElement::insertAdjacentHTML method to insert script, you must include the IHTMLScriptElement::defer attribute in the script element.

See also

Reference

IHTMLElement::innerHTML

IHTMLElement::insertAdjacentText

IHTMLElement::outerHTML

 

 

Build date: 6/12/2012