拖拽将图像放到contenteditable div中的文本上会删除chrome中的第一个单词?

时间:2013-02-27 19:20:50

标签: html5 google-chrome drag-and-drop contenteditable

这是Google Chrome(版本25.0.1364.97 m)中的错误吗? ......它在Safari中的表现如预期的那样

如果你先拖动&把一些文字放到一个有意义的div中......后来拖累了将图像或任何元素放入该文本中...并非总是如此...如果您在单词的第一个字母之前立即删除该对象...该字母已被删除...

任何想法? ......这是示例代码......

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Is this a Bug in Chrome ?<br><br>
<div id="main" contenteditable="true" style="border:solid 1px black; width:300px; height:300px" spellcheck="false" ></div>
<br><br>


Select some text and drag it into the contenteditable box ...<br><br>

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's built and run by you as part of the Stack Exchange network of Q&A sites. With your help, we're working together to build a library of detailed answers to every question about programming.
We're a little bit different from other sites. Here's how:<br><br>

Then drag and drop an image into the text ...

<img width="50px" src="http://www.gravatar.com/avatar/f7b22b86b0da570ddb5d1d4923b0f4f4" alt="">
<img width="50px" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTmjD0kayL4VTZqfYDNavlQuNvOaBd4o4HjrnNlgbNhUfVy5QfrLg" alt="">

and drag and drop it around ...<br><br>
If you drop it right before the first letter of a word ... often it deletes that first letter in Chrome ???<br><br>

Any Ideas ?

</body>
</html>

1 个答案:

答案 0 :(得分:0)

抓住了同样的错误。
我不知道是不是Chrome的错误,但是这是我的解决方法:尝试用&lt; span&gt;来包装句子中的每个单词。
它帮了我!