IE8 execCommand insertorderedlist 忽略 BR 元素
使用如下命令:
this.document.execCommand("insertorderedlist", false, argument);
在大多数浏览器中都可以正常工作,但是在 IE(包括 IE9)中,它包含太多文本。
因此,举例来说,假设您在 ContentEditable div 中有以下文本,插入符号按指定位置定位(包含 html 结构):
test<br>
<br>[caret]
test2
然后执行 execCommant,最终会在开头出现一个项目符号点,并且所有内容都缩进为该项目符号的一部分。
就像这样:
<ol>
<li> test<br>
<br>[caret]
test2
</ol>
也就是说,IE 包含仅由
分隔的周围文本。如果存在容器元素(div 或 span),它可以正常工作。
Using a command like:
this.document.execCommand("insertorderedlist", false, argument);
In most browsers works correctly, however, in IE (including IE9), it includes too much text.
So, for instance, say you have the following text in a ContentEditable div, with the caret located as specified (html included for structure):
test<br>
<br>[caret]
test2
And you then execute the execCommant, you end up with a bullet point at the the very beginning, and everything is indented as part of that bullet.
Like So:
<ol>
<li> test<br>
<br>[caret]
test2
</ol>
Which is to say, IE is including surrounding text that is only separated by a <br>
. It works correctly if there is container elements (div or span).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来唯一真正的解决方案是不使用
来分隔行。而是使用或
。
It appears the only real solution is to not use
<br>
to separate lines. Instead using<div>
or<p>
.