iframe 样式控制

Posted doduo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iframe 样式控制相关的知识,希望对你有一定的参考价值。

<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>

 


以上是关于iframe 样式控制的主要内容,如果未能解决你的问题,请参考以下文章