您必须实现自己的逻辑来修复 iframe。一种解决方案是在 iframe 上添加一个 div:
演示
$(function() {
$('#resizable').resizable({
start: function(event, ui) {
$('<div class="ui-resizable-iframeFix" style="background: #fff;"></div>')
.css({
width:'100%', height: '100%',
position: "absolute", opacity: "0.001", zIndex: 1000
})
.appendTo("body");
},
stop: function(event, ui) {
$('.ui-resizable-iframeFix').remove()
}
});
});
对于支持 CSS 属性的现代浏览器pointer-events
,有更好的解决方案,参见代码和 jsbin:
演示
$(function() {
$('#resizable').resizable({
start: function(event, ui) {
$('iframe').css('pointer-events','none');
},
stop: function(event, ui) {
$('iframe').css('pointer-events','auto');
}
});
});