The following paragraph is special. You may edit it. And with some luck – meaning localStorage
working and enabled – you will find your edits again when you return next time. To be true: it has to be using the same browser on the same computer with the same userid.
Change this as you like!
There might be better use of editing content. But this is not our topic here. We want to take a developer’s position who wants to provide editable content.
Here are some of the basics:
designMode
of the document
object which is used to specify if documents are editablecontenteditable
which is to specify if elements are editableHa! We have two options to do it. Let’s first focus on the second option:
contenteditable
is reflected in the element interface by the contentEditable
property
isContentEditable
is a read-only property of type boolean of the element interface that can be used to check if an element can be edited.
The following table shows the relationship between the attribute contentEditable
, the element property contentEditable
and the element property isContentEditable
that holds for every element.
contenteditable attribute |
contentEditable property |
isContentEditable read-only property |
---|---|---|
true |
"true" |
true |
false |
"false" |
false |
not present | "inherit" |
the value of the isContentEditable of the parent element or false |
Assume p
is an element. So what is the outcome of the following statements:
p.contentEditable=false;
p.contentEditable=!p.contentEditable;
p.contentEditable=!p.isContentEditable;
document.designMode = true;
Find the solution here.
An indication of good systems design is that it follows the principle of least surprise. How much surprise did the test hold for you?
Copyright © 2007-2024 ict-Media GmbH --- Impressum --- Datenschutzerklärung --- powered by Wordpress
Leave a Comment
You must be logged in to post a comment.