<iframe src="url" id="ifr" name="content" width="100%" frameborder="0" scrolling="no"></iframe>
<script type="text/javascript">
function adapterHeight(){
var ifr = document.getElementById("ifr");
try{
var bHeight = ifr.contentWindow.document.body.scrollHeight;
var dHeight = ifr.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
ifr.height = height;
// console.log(height);
}catch (ex){
console.log(ex);
}
}
window.onload = function(){
window.setInterval(adapterHeight, 200);
}
</script>
html组件iframe实现动态加载height属性
最新推荐文章于 2023-05-11 21:15:32 发布