如何使HTML5 contenteditable div只允许在Firefox中使用文本? [英] How to make HTML5 contenteditable div allowing only text in firefox?

查看:132
本文介绍了如何使HTML5 contenteditable div只允许在Firefox中使用文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用具有contentEditable属性的div,该属性仅允许文本。在Chrome中,可以通过以下方式轻松实现:

I want to make div with contentEditable attribute which is allowing only text. It's easily achievable in Chrome by using:

<div contenteditable="plaintext-only"></div>

但是在Firefox中不起作用。有没有办法在Firefox中使纯文本内容可编辑div?我知道这是有可能的,因为Google Plus具有这样的div,但我不知道他们是如何做到的。

However it doesn't work in Firefox. Is there a way how to make text-only contenteditable div in Firefox ? I know it is possible, because Google Plus has such div, but I don't know how they do it.

推荐答案

遗憾的是,您不能。因此, answer 指出了规范仅指定 true false 继承作为有效参数。该主题似乎已经已讨论,但如果我没错,只有Webkit才实现对仅纯文本的支持。

Sadly, you can’t. As this answer points out the spec only specifies true, false and inherit as valid parameters. The subject seems to have been discussed but if I’m not mistaken only Webkit implements support for plaintext-only.

这篇关于如何使HTML5 contenteditable div只允许在Firefox中使用文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆