0

I'm trying to convert to HTML5, but to preserve the site experience for those that don't have all the HTML5 features, I would use a workaround. For example, how can I check if the HTML5 attribute contentEditable exists, so that if it doesn't, I can just create a textarea instead.

Thaks!

3 Answers 3

1

The following snippet checks if the 'contentEditable' property exists.

if('contentEditable' in element){
   // contentEditable is available
}
else{
   // create textarea
}
Sign up to request clarification or add additional context in comments.

3 Comments

pastebin.com/aZauL5K7 I have that code, but in IE6, it doesn't display any messages
Yes, positive. var edit_region = document.getElementById('edit_region'); where <div id="edit_region"></div>
You said, it doesn't display any messages. Not even an error message? Where did you test for it's existence?
1

This can help: http://diveintohtml5.ep.io/detect.html

1 Comment

While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
0

According to HTML5 Peeks, Pokes and Pointers:

"isContentEditable" in document.createElement("a")

You can replace the document.createElement("a") with any element, really, so if you already have an element you're working with, use that.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.