Javascript 根据iframe的内容动态调整iframe的大小
我想知道一个快速的javascript解决方案,它可以根据iframe中的内容缩小/增大iframe的大小,这样就不需要滚动条了 帧源会根据用户的输入进行更改,我希望iframe会根据该更改调整其大小 我拥有的iframe代码是:Javascript 根据iframe的内容动态调整iframe的大小,javascript,html,iframe,Javascript,Html,Iframe,我想知道一个快速的javascript解决方案,它可以根据iframe中的内容缩小/增大iframe的大小,这样就不需要滚动条了 帧源会根据用户的输入进行更改,我希望iframe会根据该更改调整其大小 我拥有的iframe代码是: <iframe id="edit_add_configuration" src="<?php echo site_url();?>"> browser does not support this </iframe>
<iframe id="edit_add_configuration" src="<?php echo site_url();?>">
browser does not support this
</iframe>
获取高度和宽度
var height = document.getElementById("edit_add_configuration").contentWindow.document.body.scrollHeight;
var width = document.getElementById("edit_add_configuration").contentWindow.document.body.scrollWidth;
调整iframe的大小
document.getElementById("edit_add_configuration").style.height=height+"px";
document.getElementById("edit_add_configuration").style.width=width+"px";
iframe和外部页面是否在同一个域上?可能重复