简体   繁体   中英

HTML Rich Text Editor problems with justify* commands

I'm writing a simple Rich Text Editor which is currently working perfectly in Chrome and Firefox.

Internet Explorer however, is another story. I have finally managed to get most things working in IE with work-arounds and such, but all of my justify commands do nothing.

That is, this bit of code has no effect.

iframe.contentWindow.document.execCommand('justifyRight', false, null);

This is despite all other commands (ie: bold, italic, etc) working just fine.

Any clues as to why the justify* commands are different and not working?

I have a live demo available at http://www.hazaarmvc.com/site/test

Turns out that it was simply the content inside the editor window (an iFrame) that was the problem. It was originally generated using a Mozilla editor. Due to the differences in how each browser renders it's HTML content, IE just didn't know how to apply it's version of justifyleft, etc. Working on an empty editor everything just worked as expected.

See "Internet Explorer Differences" here: https://developer.mozilla.org/en/docs/Rich-Text_Editing_in_Mozilla for an explanation of what is different.

I'm going to chalk this one up to IE just being crap.

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