[英]How to disable autocorrect in textarea without disabling spellcheck on IE11?
似乎如果我將拼寫檢查屬性標記為 false,它會修復自動更正問題,但它不會在拼寫錯誤的單詞下划線。
<textarea id="TextArea1" spellcheck="false"></textarea>
我不想禁用拼寫檢查,但我不喜歡它的自動更正功能。 如何創建自定義拼寫檢查屬性?
注意:當最初提出這個問題時,它沒有指定 IE11。 此解決方案顯然不適用於 IE11。
請嘗試以下操作:
<textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="true"></textarea>
請記住, autocorrect
和autocapitalize
不規范的屬性,而不是瀏覽器支持。
更多信息: https : //developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#Attributes
當 HTML 不夠用時,您可以嘗試使用 JavaScript。
以下代碼可防止任何自動更正(專為 IE-11 構建):
var t = document.querySelector('#t');
var prev = '', len = 0;
t.addEventListener('keyup', function(e) {
len = t.value.length;
if(e.keyCode === 32) {
t.value = prev + ' ';
}
prev = t.value;
console.log(prev);
});
var t = document.querySelector('#t'); var prev = '', len = 0; t.addEventListener('keyup', function(e) { len = t.value.length; if(e.keyCode === 32) t.value = prev + ' '; prev = t.value; });
<textarea id='t' spellcheck='true' autocomplete='off'></textarea>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.