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!

Chiggins
  • 8,197
  • 22
  • 56
  • 81

3 Answers3

1

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

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Davis Peixoto
  • 5,695
  • 2
  • 23
  • 35
  • While this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bill the Lizard Oct 05 '11 at 18:34
1

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

if('contentEditable' in element){
   // contentEditable is available
}
else{
   // create textarea
}
Lekensteyn
  • 64,486
  • 22
  • 159
  • 192
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.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Brian Campbell
  • 322,767
  • 57
  • 360
  • 340