简体   繁体   中英

IE8 execCommand insertorderedlist ignores BR elements

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).

It appears the only real solution is to not use <br> to separate lines. Instead using <div> or <p> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM