document.queryCommandValue在Firefox中返回(空字符串) [英] document.queryCommandValue returns (empty string) in Firefox
问题描述
如果contenteditable元素中的某个文本是粗体或不粗体,我想阅读。在Chrome document.queryCommandValue(bold)
中返回true/false
一个 true / false
作为布尔值,但Firefox在开发者控制台中返回(空字符串)
。
我以小提琴为例:
http:// jsfiddle .net / nTQd2 /
如果您在div中编写som文本,请将其标记为粗体,跨度应显示true/false
或 true / false
。我真的不关心它是一个字符串还是一个布尔值,因为我可以稍后进行转换。 为粗体,斜体和类似的,使用 文档.queryCommandState()
。对于非布尔命令使用 document.queryCommandValue()
I want to read if a certain text in a contenteditable element is bold or not. In Chrome document.queryCommandValue("bold")
returns "true"/"false"
as a string, IE returns a true/false
as a boolean, but Firefox returns (empty string)
in the developer console.
I made a fiddle as an example: http://jsfiddle.net/nTQd2/
If you write som text in the div, mark it and then hit "Bold" the span should show "true"/"false"
or true/false
. I don't really care if its as a string or a boolean as I can convert it later.
For bold, italic and similar, use document.queryCommandState()
. Use document.queryCommandValue()
for non-Boolean commands.
这篇关于document.queryCommandValue在Firefox中返回(空字符串)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!