Gets or sets the HTML between the start and end tags of the object.
HRESULT IHTMLElement::get_innerHTML(BSTR *p);HRESULT IHTMLElement::put_innerHTML(BSTR v);
- Pointer to a variable of type BSTR that receives the content between the start and end tags.
- BSTR that specifies the content between the start and end tags.
Returns S_OK if successful, or an error value otherwise.
The IHTMLElement::innerHTML property is valid for both block and inline elements. By definition, elements that do not have both an opening and closing tag cannot have an IHTMLElement::innerHTML property.
The IHTMLElement::innerHTML property takes a string that specifies a valid combination of text and elements. When the IHTMLElement::innerHTML property is set, the given string completely replaces the existing content of the object. If the string contains HTML tags, the string is parsed and formatted as it is placed into the document.
This property is accessible at run time as the document is being parsed; however, removing elements at run time, before the document is fully loaded, could prevent other areas of the document from rendering.
You can change the value of the title element using the document.title property.
To change the contents of the table, tFoot, tHead, and tr elements, use the table object model described in Building Tables Dynamically. However, to change the content of a particular cell, you can use IHTMLElement::innerHTML.
Security Alert Improper handling of the IHTMLElement::innerHTML property can enable script-injection attacks. When accepting text from an untrusted source (such as the query string of a URL), use IHTMLDocument3::createTextNode to convert the HTML to text, and append the element to the document using IHTMLDOMNode::appendChild. Refer to the Examples section below for more information.
To maintain compatibility with earlier versions of Windows Internet Explorer, this property applies to the textArea object. However, the property works only with strings that do not contain tags. With a string that contains a tag, this property returns an error. It is better to use the IHTMLElement::innerText property with this object.