Export (0) Print
Expand All

insertAdjacentHTML method

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

Syntax


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

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.

Standards information

There are no standards that apply here.

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

 

 

Community Additions

ADD
Show:
© 2014 Microsoft