简体   繁体   English

IE9中的contentEditable iframe中的空div

[英]Empty div in a contentEditable iframe in IE9

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<iframe id="rte" style="width: 600px; height:300px"></iframe>

<script type='text/javascript'>

  $(document).ready(function() {
    $('#rte').contents().find('body').prop('contentEditable', true);
    $('#rte').contents().find('body').html('123<div></div>456');
  });

</script>​

http://jsfiddle.net/JsjCJ/ http://jsfiddle.net/JsjCJ/

This renders in ie7, ie8, firefox, chrome: 这将在ie7,ie8,firefox,chrome中呈现:

123
456

But it becomes in ie9: 但是它变成了ie9:

123

456

Is there a way to fix this bug? 有没有办法解决这个错误?

Have you tried applying css property div{height:auto;margin:0px;padding:0px;} . 您是否尝试过应用CSS属性div{height:auto;margin:0px;padding:0px;} If that doesn't solve the issue, Try applying border to the div element in-between and check whether it actually has some default height assigned to the <div> element 如果这样不能解决问题,请尝试在其间的div元素上应用边框,并检查其是否实际上已为<div>元素分配了一些默认高度

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM