canHaveChildren Property

MS Office DHTML, HTML & CSS

canHaveChildren Property


Retrieves a value indicating whether the object can contain children.

Syntax

HTML N/A
Scripting [ bChildren = ] object.canHaveChildren

Possible Values

bChildren Boolean that specifies whether the object can be a parent to child objects.

The property is read-only with no default value.

Remarks

Objects do not have to contain children for the canHaveChildren property to return true. This property is useful in determining whether objects can be appended as children.

Example

This example uses the canHaveChildren property to add a new object to the first element in a Web page that can contain children.

Sample Code

<SCRIPT>
window.onload=fnInit;
function fnInit(){
   var oNewObject=document.createElement("SPAN");
   var oNewText=document.createTextNode("Test");
   oNewObject.appendChild(oNewText);
   for(var i=0;i<document.all.length;i++){
      if(document.all[i].canHaveChildren==true){
        document.all[i].appendChild(oNewObject);
        break;
     }
   }
}
</SCRIPT>
<INPUT TYPE=button VALUE="Add Child" onclick="fnAddChild()">
<DIV ID=oGrandParent STYLE="background-color: #CFCFCF;">
<WBR>WBR - </WBR>
<BR>
<NOBR>NOBR - </NOBR>
<P>P - <s/P>
</DIV>
This feature requires Internet Explorer 5 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
A, ACRONYM, ADDRESS, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, custom, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FONT, FORM, FRAMESET, HEAD, Hn, HTML, I, IFRAME, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

See Also

appendChild, createElement, createTextNode


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.