isContentEditable Property (A, ABBR, ACRONYM, ...)

Switch View :
ScriptFree
isContentEditable Property

Gets the value that indicates whether the user can edit the contents of the object.

Syntax

HTML N/A
Scripting [ bCanEdit = ] object.isContentEditable

Possible Values

bCanEdit Boolean that receives one of the following values.
false
The content cannot be edited.
true
The content can be edited.

The property is read-only. The property has no default value.

Example

The following example shows how to use the isContentEditable property to determine whether the user can edit the content of an object.


<head>
<SCRIPT>
function chgSpan() {
    currentState = oSpan.isContentEditable;
    newState = !currentState;
    oSpan.contentEditable = newState;
    oCurrentValue.innerText = newState;
    newState==false ? oBtn.innerText="Enable Editing" :
        oBtn.innerText="Disable Editing"
}
</SCRIPT>
</head>
<body onload="oCurrentValue.innerText = oSpan.isContentEditable;">
<P>Click the button to enable or disable SPAN content editing.</P>
<P>
<BUTTON ID="oBtn" onclick="chgSpan()">Enable Editing</BUTTON>
</P>
<P><SPAN ID="oSpan">You can edit this text.</SPAN></P>
Span can be edited: <SPAN ID="oCurrentValue"></SPAN>
</body>

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/editRegions.htm

Applies To

A, ABBR, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BDO, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, CUSTOM, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HEAD, hn, HR, HTML, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, ISINDEX, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, nextID, NOBR, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, RT, RUBY, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XML, XMP, Element Constructor
Community Content

spiroc
Not working with Vista

This functionality no longer works with Vista and IE7. It becomes impossible to place the cursor in a specified location in the content editable div. The cursor always goes to the first space in the div. Is there a fix to this problem???