例如:
<iframe name="Stack" src="http://stackoverflow.com/" width="740"
frameborder="0" scrolling="no" id="iframe"> ...
</iframe>
我希望它能够根据里面的内容调整它的高度,而不需要使用滚动。
将其添加到您的<head>
部分:
<script>
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px';
}
</script>
并将您的 iframe 更改为:
<iframe src="..." frameborder="0" scrolling="no" onload="resizeIframe(this)" />
正如发现的站点讨论 https://www.sitepoint.com/community/t/auto-height-iframe-content-script/67843.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)