Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

canHaveHTML

Property of dom/HTMLElementdom/HTMLElement

Syntax

var result = element.canHaveHTML;
element.canHaveHTML = value;

Examples

The following example shows how to use the canHaveHTML property to determine whether an object can contain HTML markup.

<HTML>
<HEAD>
<SCRIPT>
function answer(arg) {
    arg ? alert("Yes") : alert("No");
}
</SCRIPT>
</HEAD>
<BODY>
<P>INPUT: <INPUT type="text" ID="oInput" VALUE="oInput" /></P>
<P>SPAN: <SPAN ID="oSpan">oSpan</SPAN></P>
<BUTTON onclick="answer(oInput.canHaveHTML);">
Can the INPUT contain HTML?
</BUTTON>&nbsp;
<BUTTON onclick="answer(oSpan.canHaveHTML);">
Can the SPAN contain HTML?
</BUTTON>
</BODY>
</HTML>

View live example

Notes

Remarks

The property is read-only for all objects except the following, for which it is read-write: defaults.

Syntax

Attributions