<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>
这在 ie7、ie8、firefox、chrome 中呈现:
123
456
但是在ie9中就变成了:
123
456
有没有办法修复这个错误?
最佳答案
您是否尝试过应用 css 属性 div{height:auto;margin:0px;padding:0px;}
.如果这不能解决问题,请尝试在中间的 div 元素上应用边框,并检查它是否确实为 <div>
分配了一些默认高度。元素
希望这对您有所帮助!
关于html - IE9 中 contentEditable iframe 中的空 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12844844/