iframe 样式控制
<iframe src="..." 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;overflow-x:auto; overflow-y:hidden;";
//获取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>