【文件属性】:
文件名称:iframeless:自动调整 iframe 的大小以匹配其内容的高度并且根本没有滚动条
文件大小:7KB
文件格式:ZIP
更新时间:2021-06-28 07:01:11
JavaScript
无框架
自动调整 iframe 的大小以匹配其内容的高度并且根本没有滚动条。
演示
跨浏览器测试
自动调整大小的代码
var iframe = document.querySelector('iframe');
iframe.onload = function() {
iframe.height = Math.max(
iframe.contentDocument.body.scrollHeight || 0,
iframe.contentDocument.body.offsetHeight || 0,
iframe.contentDocument.clientHeight || 0,
iframe.contentDocument.scrollHeight || 0,
iframe.contentDocument.offsetHeight
【文件预览】:
iframeless-master
----index-no-resize.html(588B)
----iframe.css(40B)
----index.html(554B)
----index.css(93B)
----README.md(856B)
----iframe.html(9KB)
----index.js(418B)
----index-no-resize.js(683B)