简体   繁体   English

为什么@contenteditable 在 iPhone 上不起作用?

[英]Why doesn't @contenteditable work on the iPhone?

Safari HTML Reference: Supported Attributes says: Safari HTML 参考:支持的属性说:

contenteditable内容可编辑

If true, the element can be edited on the fly;如果为 true,则可以即时编辑该元素; if false, it cannot.如果为假,则不能。

Availability可用性

Available in Safari 1.2 and later.在 Safari 1.2 及更高版本中可用。 Available in iPhone OS 1.0 and later.适用于 iPhone OS 1.0 及更高版本。

However, on my iPhone, I can't get it to work.但是,在我的 iPhone 上,我无法让它工作。 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).您可以使用此文档进行尝试(诚然不是纯 html,但该文档适用于桌面 Safari、Chrome 和 Firefox 3)。 I haven't been able to get even the simplest html document to be editable in mobile Safari.我连最简单的 html 文档都无法在移动 Safari 中进行编辑。

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.根据 WWDC 2011 的开发者视频之一, contenteditable已添加到 iOS 5 beta 2。我建议注册 Apple 的Safari 开发者计划并从 WWDC 视频页面下载该视频。

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.如果您注册成为 Safari 开发人员,您还可以获得将您的网站提交到他们的在线 iOS Web 应用程序库的特权。

Edit: I've confirmed this works on my iPad running iOS 5.0.1.编辑:我已经确认这适用于运行 iOS 5.0.1 的 iPad。 Try it out here: http://www.quirksmode.org/dom/execCommand/在这里试试: http : //www.quirksmode.org/dom/execCommand/

It works, kind of.它有效,有点。 I thought contenteditable doesn't work on iPhone before.我认为 contenteditable 之前在 iPhone 上不起作用。 When I set a div to contenteditable I couldn't move the cursor/pointer to where I wanted to move it.当我将 div 设置为 contenteditable 时,我无法将光标/指针移动到我想要移动的位置。 But, when I was fiddling around XHTML with contentEditable within iBooks.app on iPad, I found that "execCommand('insertText', null, 'foobar');"但是,当我在 iPad 上的 iBooks.app 中使用 contentEditable 摆弄 XHTML 时,我发现“execCommand('insertText', null,'foobar');” worked within Mobile Safari.在 Mobile Safari 中工作。

如果您愿意,您可以使用巧妙的 css 和 javascript 制作一个虚拟键盘,并将其制作成书签。

If you cannot focus the contenteditable element try adding this to your css如果您无法聚焦 contenteditable 元素,请尝试将其添加到您的 css 中

[contenteditable] {
    -webkit-user-select: text;
    user-select: text;
}

The design mode and content editable are working fine in IOS 5.But in previous versions it is not working.There is post设计模式和内容可编辑在IOS 5中工作正常。但在以前的版本中它不起作用。有帖子

http://mobile.tutsplus.com/tutorials/mobile-web-apps/safari-5_html5/ http://mobile.tutsplus.com/tutorials/mobile-web-apps/safari-5_html5/

I think this is because editing HTML requires quite an advanced user interface.我认为这是因为编辑 HTML 需要相当先进的用户界面。 That's why desktop Safari implements it, while Mobile Safari doesn't.这就是桌面 Safari 实现它,而移动 Safari 没有实现的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM