代码之家  ›  专栏  ›  技术社区  ›  Michiel de Mare

禁用HTML文本字段的拼写检查

  •  241
  • Michiel de Mare  · 技术社区  · 16 年前

    我是否可以在HTML文本字段(如Safari)上禁用拼写检查?

    5 回复  |  直到 6 年前
        1
  •  356
  •   Community CDub    7 年前

    更新 :根据评论人的建议(附加学分 How can I disable the spell checker on text inputs on the iPhone )用于处理所有桌面和移动浏览器。

    <tag autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
    

    原始答案:javascript不能覆盖用户设置,所以除非使用文本字段以外的其他机制,否则这是不可能(或不应该)的。

        2
  •  174
  •   John Weisz    7 年前

    是的,使用 spellcheck="false" ,如由 HTML5 例如:

    <textarea spellcheck="false">
        ...
    </textarea>
    
        3
  •  7
  •   JCOC611    14 年前

    iframe将“触发”拼写检查器(如果其内容可编辑设置为true),就像文本字段一样,至少在chrome中是这样。

        4
  •  5
  •   Alex Kolarski    6 年前

    对于Grammarly,您可以使用:

    <textarea data-gramm="false" />
    
        5
  •  2
  •   Artur INTECH    6 年前

    以下代码段将禁用所有代码段 textarea input[type=text] 元素:

    (function () {
        function disableSpellCheck() {
            let selector = 'input[type=text], textarea';
            let textFields = document.querySelectorAll(selector);
    
            textFields.forEach(
                function (field, _currentIndex, _listObj) {
                    field.spellcheck = false;
                }
            );
        }
    
        disableSpellCheck();
    })();