禁用 HTML 文本字段的拼写检查
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/254712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable spell-checking on HTML textfields
提问by Michiel de Mare
Can I somehow disable spell-checking on HTML textfields (as seen in e.g. Safari)?
我可以以某种方式禁用对 HTML 文本字段的拼写检查(如在 Safari 中看到的)吗?
回答by Eric Wendelin
Update: As suggested by a commenter (additional credit to How can I disable the spell checker on text inputs on the iPhone), use this to handle all desktop and mobile browsers.
更新:正如评论者所建议的(对如何在 iPhone 上的文本输入上禁用拼写检查器的额外功劳),使用它来处理所有桌面和移动浏览器。
<tag autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
Original answer: Javascript cannot override user settings, so unless you use another mechanism other than textfields, this is not (or shouldn't be) possible.
原始答案:Javascript 无法覆盖用户设置,因此除非您使用文本字段以外的其他机制,否则这不可能(或不应该)。
回答by Ms2ger
回答by sensor
For Grammarly you can use:
对于语法,您可以使用:
<textarea data-gramm="false" />
回答by JCOC611
An IFrame WILL "trigger" the spell checker (if it has content-editable set to true) just as a textfield, at least in Chrome.
IFrame 会像文本字段一样“触发”拼写检查器(如果它的 content-editable 设置为 true),至少在 Chrome 中是这样。
回答by Artur Beljajev
The following code snippet disables it for all textarea
and input[type=text]
elements:
以下代码片段为所有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();
})();