IE8, IE9, IE10 Blinking Cursor Issue

安稳与你 提交于 2019-12-07 08:09:07

问题


I am making an editor which shows a toolbar on some text selection. The issue that I am facing in IE is that the blinking cursor still shows above the toolbar. This is specifically happening in IE. The blinking cursor comes on top.

Here is the sample for this issue:

$('.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>

Taking the focus out is not an option as there are more components in this application and this fix will not work for those situations. The fix needs to be completely autonomous.


回答1:


Just add

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

And cursor will stop blinking on IE7-IE10 (tested)

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

UDP1 Sorry didn't see your update about 'focus' not been an option...



来源:https://stackoverflow.com/questions/13760093/ie8-ie9-ie10-blinking-cursor-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!