iframe 根据内容自适应高度-终极解决方案
在主页面 iframe onLoad 时间里面写
function iframeLoad()
{
document.getElementById("iframe").height=0;
document.getElementById("iframe").height=document.getElementById("iframe").contentWindow.document.body.scrollHeight;
}
下面是示例代码
function changeFrameHeight(){
document.getElementById("myiframe").height=0;
document.getElementById("myiframe").height=document.getElementById("myiframe").contentWindow.document.body.scrollHeight;
}
window.onresize=function(){
changeFrameHeight();
}
时间:(2024-02-06 14:21:19)
本站资源均来自互联网或会员发布,如果不小心侵犯了您的权益请与我们联系。我们将立即删除!谢谢!