问题描述
< div contenteditable 我试图在拼写检查时创建一个简单的可编辑字段=contenteditablespellcheck =spellchecklang =en>文字< / div>
(。
更新:
< html lang =en>
< body>
< textarea>< / textarea>
< textarea lang =fr>< / textarea>
< div lang =ru>
< textarea>< / textarea>
< / div>
< / body>
< / html>
在这个HTML片段中,第一个 如果一个元素指定了一种语言,并且用户没有安装字典,那么$ c $将被英文拼写检查,第二个用法文检查,第三个用俄语拼写。对于该语言,拼写检查在默认情况下是禁用的,尽管用户可以选择手动启用它。 希望这有助于某种方式。唯一的问题是你需要点击div内(如果你使用JS解决方案)检查拼写错误。 I'm trying to create a simple editable field (for posting) while combining a spellcheck: (http://www.wufoo.com/html5/attributes/17-spellcheck.html) It works, but on Google Chrome, the spellchecker doesn't detect the language. (despite the specified @lang attribute) The "bug" was fixed in Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=338427 But I can't find anything about Google Chrome's implementation of this. Is there a way to notify the spellchecker about the expected language in an HTML5 field? Maybe something in the The According to W3Schools: When I visit the link you mentioned above (in Chrome 22) there are some bugs. The spellchecker says on "key" it's mispelled, and double clicking on some words makes it indicated as misspelled, too. I had Hungarian selected as spellchecking language. NOTE: The language can be changed by right-clicking on the input, but you need to reload the page. Also there are some browsers where spellchecking is turned of in the settings. As I saw in the comments, bwitkowicz mentioned a solution with JS. Also I have found an example working with textareas. Check this fiddle.< textarea> $ c
<div contenteditable="contenteditable" spellcheck="spellcheck" lang="en">text</div>
<head>
like charset
, meta lang
, etc?spellcheck
attribute is not implemented in all browsers yet. If it is, there are some bugs need to be fixed.function updateStatus() {
console.log("updating");
$("#spellStatus").text( String( $("#textContent").attr("spellcheck") ) );
$("#editStatus").text( String( $("#textContent").attr("contentEditable") ) );
}
$(function() {
updateStatus();
$("#spell").ready(function() {
console.log("spell");
$("#textContent").attr( "spellcheck", function(ix,old) {
old = old === "false" ? false : true;
console.log("setting " + (!old));
return old;
});
});
$("#edit").ready(function() {
console.log("edit");
$("#textContent").attr( "contentEditable", function(ix,old) {
old = old === "false" ? true : false;
console.log("setting " + (!old));
return !old;
});
});
$("#spell, #edit").ready(updateStatus);
});
#spell, #edit, #spellStatus, #editStatus {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div><button id="spell">Toggle Spellcheck</button><span id="spellStatus"></span></div>
<div><button id="edit">Toggle Editable</button><span id="editStatus"></span></div>
<div id="textContent" style="padding: 5px; border: 1px solid black;">
Here is some texxt with spellung erreurs. Also you have to click inside the div to chekc erorrrrs.
</div>
UPDATE:
<html lang="en">
<body>
<textarea></textarea>
<textarea lang="fr"></textarea>
<div lang="ru">
<textarea></textarea>
</div>
</body>
</html>
In this HTML snippet, the first <textarea>
will be spell checked in English, the second in French, and the third in Russian.
If an element specifies a language, and the user has no dictionary installed for that language, spell check is disabled by default, although the user may choose to manually enable it.
Hope that helps some way. The only problem is you need to click inside the div (if you use the JS solution) to check misspelling.
这篇关于在谷歌浏览器中设置拼写检查语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!