问题描述
我有以下HTML意图确保内部跨度
不可编辑。这适用于其他浏览器,但不适用于IE8。
< div contenteditable =true>
卢克,我是你的父亲。
< span contenteditable =false>我是你的儿子? EWWW<!/跨度>
不要回覆我!
< / div>
下面是一个JSFiddle来说明这一点(使用IE8测试它):。
我如何确保IE8能正确处理这个问题?
好的,我已经发现了答案就像一样。你看,玩这个代码,我错误地将 contenteditable
设置为 true
c> span 和瞧!它的工作!
因此,要在contenteditable div内创建 span
NON-contenteditable,您只需将其 contenteditable
属性为 true
!
< div contenteditable =true>
卢克,我是你的父亲。
< span contenteditable =true>我是你的儿子? EWWW<!/跨度>
不要回覆我!
< / div>
以下是演示文件(使用IE8打开它):。
最后,我没有发布问题获得投票(尽管他们不会受到伤害!),但由于解决方案非常荒谬,而且我没有在这里找到它,所以我认为有人可能会发现此技巧节省时间。
I have the following HTML intending to make sure that the inner span
isn't editable. This works in other browsers but not IE8.
<div contenteditable="true">
Luke, I am your father.
<span contenteditable="false">I'm your son?! Ewww!</span>
Don't speak back to me!
</div>
Here's a JSFiddle to illustrate the point (use IE8 to test it): http://jsfiddle.net/haxhia/uUKPA/3/ .
How do I make sure that IE8 treats this properly as well?
Okay, I already have discovered the answer much like how Penicillin was discovered.
You see, playing around with this code, I mistakenly set contenteditable
to true
for the span
and voila! It worked!
So, to make a span
NON-contenteditable inside a contenteditable div, you just set its contenteditable
attribute to true
!
<div contenteditable="true">
Luke, I am your father.
<span contenteditable="true">I'm your son?! Ewww!</span>
Don't speak back to me!
</div>
Here's the file to demonstrate (use IE8 to open it): https://www.dropbox.com/s/2yc3rrtkji3rupr/contenteditableIE8.html .
Lastly, I didn't post the question to get votes (although, they wouldn't hurt!), but since the solution was so ridiculous and I didn't find it here, I thought someone may find this tip time saving.
这篇关于contenteditable = true内部contenteditable = true块在IE8中仍然可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!