根据内容调整iFrame的大小'高度只能扩大?

时间:2017-07-27 23:30:44

标签: javascript jquery html iframe

看看附带的codepen,看看我的意思。尝试减小浏览器的宽度,框架应正确调整大小。然后最大化您的浏览器窗口并注意框架不会重新调整其高度。

我有多个框架堆叠在一起,所以这是一个非常烦人的问题。

我尝试过使用.height(),. OUTHeight(),. innerHeight(),.。scrollHeight和.clientHeight无效。

https://codepen.io/anon/pen/gxaLPW

var newHeight = $('#frame').contents().height();  
$('#frame').attr('height', newHeight);

提前感谢您提供任何/所有帮助!

2 个答案:

答案 0 :(得分:1)

试试这个

function resizeFrame() {
  var newHeight = $('#frame').contents().find("body").height();
  $('#frame').attr('height', newHeight + 20);
}

答案 1 :(得分:0)

尝试这个

/system/app-priv/<app_name>

相关问题