4

我正在制作一个在某些文本选择上显示工具栏的编辑器。我在 IE 中面临的问题是闪烁的光标仍然显示在工具栏上方。这特别发生在 IE 中。闪烁的光标出现在顶部。

这是此问题的示例:

$('.content').mouseup(function(e) {
  $('.shy').css({
    top: e.pageY - 30 + 'px',
    left: e.pageX - 30 + 'px'
  });
  $('.shy').show();
});
.content {
  height: 300px;
  width: 300px;
  border: 1px solid black;
  overflow: hidden;
  word-wrap: break-word;
  z-index: 1;
}
.shy {
  height: 100px;
  width: 100px;
  background-color: orange;
  z-index: 2;
  overflow: hidden;
  word-wrap: break-word;
  display: none;
  position: absolute;
}
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<div contenteditable="true" class='content'>Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content Content</div>
<div class='shy'>
  <div>

将焦点移出不是一种选择,因为此应用程序中有更多组件,并且此修复程序不适用于这些情况。修复需要完全自主。

4

1 回答 1

0

只需添加

$('.shy').focus();

光标将在 IE7-IE10 上停止闪烁(已测试)

http://jsfiddle.net/2QAxk/6/

UDP1 抱歉没有看到您关于“焦点”的更新不是一个选项...

于 2012-12-07T10:24:49.197 回答