简体   繁体   English

在 FireFox 的 contenteditable div 中关闭语法更正

[英]Turn off grammar correction in a contenteditable div in FireFox

I have contenteditable div with text on it.我有内容可编辑的 div,上面有文字。 In firefox, there is some kind of grammar correction which underlines the text with red marking.在 Firefox 中,有某种语法更正,用红色标记突出显示文本。 How can I turn it off?我怎样才能关闭它?为什么-you-underline-me-image

How do I turn off the red markings in FireFox?如何关闭 FireFox 中的红色标记?

<div contenteditable ='true'>Why do you underline me?</div>

JSFiddle: http://jsfiddle.net/26JkW/ JSFiddle: http : //jsfiddle.net/26JkW/

Try --尝试 -

<textarea spellcheck="false"></textarea>

Since the above is a Firefox-only attribute, if you're concerned about validation, you can also use jQuery to set the attribute, eg由于上面是Firefox-only属性,如果你关心验证,你也可以使用jQuery来设置属性,例如

$('.textarea_you_want_to_target').attr('spellcheck', false);


Update更新

It seems in Firefox you have to set spellcheck="false" on <body> .在 Firefox 中,您似乎必须在<body>上设置spellcheck="false" See http://jsfiddle.net/26JkW/5/http://jsfiddle.net/26JkW/5/

According to MDN :根据MDN

Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6), the spell checker uses the <input> element's lang attribute to determine the default spell checker language.从 Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6) 开始,拼写检查器使用<input>元素的 lang 属性来确定默认拼写检查器语言。 If <input> doesn't have a lang attribute, that attribute is searched each successive parent element and upward toward the root node until one is found.如果<input>没有 lang 属性,则在每个连续的父元素中搜索该属性,并向上朝根节点搜索,直到找到一个。

So to disable spellcheck, not only do I add spellcheck="false" , but I also add a lang tag with a dictionary not found on the users computer.所以要禁用拼写检查,我不仅添加了spellcheck="false" ,而且还添加了一个带有用户计算机上找不到的字典的lang标记。

<div contentEditable="true" lang="klingon" spellcheck="false"></div>

This should work on most systems outside of Kronos.这应该适用于 Kronos 以外的大多数系统。

There is no grammar-checking native to Firefox. Firefox 没有原生的语法检查。 Given that every word is being marked as incorrect, it is possible that you have the wrong language selected.鉴于每个单词都被标记为不正确,您可能选择了错误的语言。

To verify that you have the correct language selected for Firefox's dictionary: When typing in an editable field, right-click the input area.要验证您是否为 Firefox 的词典选择了正确的语言: 在可编辑字段中输入时,右键单击输入区域。 From the context menu, there is an option Languages.从上下文菜单中,有一个选项语言。 Ensure the expected language is selected.确保选择了预期的语言。


EDIT stealthyninja's answer below contains the method for disabling spell checking as the OP requested.下面编辑隐藏忍者的答案包含根据 OP 的要求禁用拼写检查的方法。 This answer should not be taken as the solution.这个答案不应该被当作解决方案。

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

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