IE中内联contenteditable元素之前和之后的换行符 [英] Line break before and after inline contenteditable element in IE

查看:158
本文介绍了IE中内联contenteditable元素之前和之后的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使内联元素 contenteditable 。对于Chrome / Firefox,它工作正常,但如果 contenteditable ,则IE(至少11)会在跨度前后插入换行符。



链接到小提琴:



这是IE:





有什么办法可以解决?



UPD:



我的IE版本:





我的小提琴页面上的IE模式:





另外,我正在使用Windows 7 Professional,64位

解决方案

请注意: contentEditable 在所有浏览器甚至所有版本中均存在极高的错误且不一致。使用像CKEditor这样的JS WYSIWYG编辑器(可以内联编辑)要好得多。例如,某些浏览器在< p> <中按 Enter 时,将换行上一个文本块。 div> < span> ,而其他人将输入< br> 。有时< br> 或两个必须位于开头或结尾。两个< br> 计为一行...直到没有。 IE在表或内联元素中不正确支持 contentEditable 粘贴会插入HTML而不是文本。这些问题不断发生,并将使您无尽的挫败感。


I need to make inline element contenteditable. It works fine for Chrome/Firefox, but IE (11 at least) inserts line break before and after span if it's contenteditable.

Link to fiddle: https://jsfiddle.net/nokpy02g/1/

This is how it looks like in Chrome:

And this is IE:

Is there is any way to fix it?

UPD:

My IE version:

IE mode on my fiddle page:

Also, I am using Windows 7 Professional, 64bit

解决方案

Be aware: contentEditable is extremely buggy and inconsistent across all browsers and even versions. You are much, much better of using a JS WYSIWYG editor like CKEditor (which can edit inline). For example, some browsers will wrap the previous block of text when pressing Enter in a <p> or <div> or <span>, while others will enter <br>. Sometimes a <br> or two must be at the front or end. Two <br>s count as a single line...until it doesn't. IE doesn't support contentEditable properly in table or inline elements. Pasting inserts HTML rather than text. The problems go on and on, and will cause you endless frustration.

这篇关于IE中内联contenteditable元素之前和之后的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆