Turn off grammar correction in a contenteditable d

2019-02-21 18:46发布

I have contenteditable div with text on it. In firefox, there is some kind of grammar correction which underlines the text with red marking. How can I turn it off? Why-do.you-underline-me-image

How do I turn off the red markings in FireFox?

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

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

3条回答
forever°为你锁心
2楼-- · 2019-02-21 19:06

There is no grammar-checking native to 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. 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. This answer should not be taken as the solution.

查看更多
我只想做你的唯一
3楼-- · 2019-02-21 19:14

According to 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. 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.

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.

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

This should work on most systems outside of Kronos.

查看更多
祖国的老花朵
4楼-- · 2019-02-21 19:18

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, e.g.

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


Update

It seems in Firefox you have to set spellcheck="false" on <body>. See http://jsfiddle.net/26JkW/5/

查看更多
登录 后发表回答