Web host music - 218Part IIIDocument Objects ReferenceThe purpose and names of
Wednesday, October 17th, 2007218Part IIIDocument Objects ReferenceThe purpose and names of the clientLeftand clientTopproperties are confusing at best. Unlike the clientHeightand clientWidthproperties, which apply to the content of an element, the clientLeftand clientTopproperties return essentially no more informationthan the thickness of a border around an element provided the element is positioned. Ifyou do not specify a border or do not position the element, the values are zero (although the document.bodyobject can show a couple of pixels in each direction without explicit settings). If you are trying to read the left and top coordinate positions of an element, theoffsetLeftand offsetTopproperties are more valuable in WinIE; as shown in Listing 15-6, however, the clientTopproperty returns a suitable value in MacIE. Virtually all elementshave the clientLeftand clientTopproperties in IE5+; in IE4, the properties apply only tothe body, button, caption, embed, fieldset, legend, marquee, and textareaobjects. Related Items:offsetLeft, offsetTopproperties. contentEditableValue:Boolean.Read/Write Compatibility:WinIE5.5+, MacIE-, NN-, Moz-, Safari- IE5.5 introduced the concept of editable HTML content on a page. Element tags can include acontenteditableattribute, whose value is echoed via the contentEditableproperty ofthe element. The default value for this property is inherit, which means that the propertyinherits whatever setting this property has in the hierarchy of HTML containers outward tothe body. If you set the contentEditableproperty to true, that element and all nested ele- ments set to inherit the value become editable; conversely, a setting of falseturns off theoption to edit the content. ExampleListing 15-7 demonstrates how to use the contentEditableproperty to allow a piece of textto be edited. When you click the button of a freshly loaded page, the toggleEdit()functioncaptures the opposite of the current editable state via the isContentEditableproperty ofthe divthat is subject to edit. You switch on editing for that element in the next statement byassigning the new value to the contentEditableproperty of the div. For added impact, turnthe text of the divto red to provide additional user feedback about what is editable on thepage. You can also switch the button label to one that indicates the action invoked by thenext click on it. Listing 15-7: Using the contentEditable Property
elementObject.clientLeft