【发布时间】:2015-12-22 18:31:05
【问题描述】:
我正在构建的网站上有一个 iframe。问题是,我在框架内显示的其中一个页面有一些动态内容(单击时会扩展和降低高度),是否有办法让 iframe 也随内容一起调整大小?
它会加载静态页面的大小,但是一旦页面上的项目被点击并展开,iframe 就不会随之展开。
我现在只是基本的,这是我的<head>内容:
<script language="javascript" type="text/javascript">
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
</script>
这是我的 iframe:
<iframe src="index2.php" name="frame" frameborder="0" scrolling="no" onload="resizeIframe(this)" />
【问题讨论】:
-
您好,欢迎来到 StackOverflow!提供minimal, complete and verifiable example 会很有帮助。
标签: javascript css iframe