Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't @contenteditable work on the iPhone?

Safari HTML Reference: Supported Attributes says:

contenteditable

If true, the element can be edited on the fly; if false, it cannot.

Availability

Available in Safari 1.2 and later. Available in iPhone OS 1.0 and later.

However, on my iPhone, I can't get it to work. Anyone have success with this?

You can try it with this document (admittedly not pure html, but that document works in desktop Safari, and Chrome and Firefox 3). I haven't been able to get even the simplest html document to be editable in mobile Safari.

like image 342
JasonPlutext Avatar asked Apr 06 '09 23:04

JasonPlutext


People also ask

Why you shouldn t use contenteditable?

For many ContentEditable implementations on the web, some invisible character or empty span tag may slip into the HTML, so that two ContentEditable elements behave totally differently (even though they look the same). The experience can be maddening to users, and hard for engineers to debug.

How does contenteditable work?

The contenteditable global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.

What is contenteditable?

The contenteditable attribute specifies whether the content of an element is editable or not. Note: When the contenteditable attribute is not set on an element, the element will inherit it from its parent.


2 Answers

contenteditable has been added to iOS 5 beta 2, according to one of the developer videos from WWDC 2011. I suggest signing up to Apple's Safari developer program and downloading that video from the WWDC videos page.

If you sign up to be a Safari dev, you also gain the privilege to submit your Website to their online iOS Web app gallery.

Edit: I've confirmed this works on my iPad running iOS 5.0.1. Try it out here: http://www.quirksmode.org/dom/execCommand/

like image 115
kirb Avatar answered Sep 19 '22 23:09

kirb


It works, kind of. I thought contenteditable doesn't work on iPhone before. When I set a div to contenteditable I couldn't move the cursor/pointer to where I wanted to move it. But, when I was fiddling around XHTML with contentEditable within iBooks.app on iPad, I found that "execCommand('insertText', null, 'foobar');" worked within Mobile Safari.

like image 21
freedom Avatar answered Sep 22 '22 23:09

freedom