iframe根据内容的高度和宽度适应
<iframe src="https://www.baidu.com" id="iframe" frameborder="0" scrolling="no"
onload="changeFrameHeight()"></iframe>
<script type="text/javascript" language="javascript">
function changeFrameHeight() {
var ifm = document.getElementById("iframe");
ifm.height = document.documentElement.clientHeight;
ifm.width = document.documentElement.clientWidth;
console.log("高度",document.documentElement.clientHeight);
}
window.onresize = function() {
changeFrameHeight();
}
</script>
网友评论