标签:get framewin hang bre 获取 lin body 样式 content
<iframe src="..." scrolling="no" id="iframe"></iframe>
<script> function changeFrameHeight() { var ifm = document.getElementById("iframe"); var iframeWindow = ifm.contentWindow; var body = ifm.contentWindow.document.body; if (iframeWindow.document.readyState == "complete") { var iframeWidth, iframeHeight; body.style.cssText = "word-wrap:break-word;"; //获取Iframe的内容实际宽度 iframeWidth = iframeWindow.document.documentElement.scrollWidth; //获取Iframe的内容实际高度 iframeHeight = iframeWindow.document.documentElement.scrollHeight; //设置Iframe的宽度 ifm.width = ‘500px‘; //设置Iframe的高度 ifm.height = iframeHeight; } } window.onresize = function () { changeFrameHeight(); } window.onload = function () { changeFrameHeight(); } </script>
标签:get framewin hang bre 获取 lin body 样式 content
原文地址:https://www.cnblogs.com/Doduo/p/9739172.html