<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> function resizeIframe(){ var myframe=document.getElementById("myframe"); try{ var bodyHeight=myframe.contentWindow.document.body.scrollHeight; var scrollHeight=0 if(myframe.contentWindow.documentElement){ scrollHeight=myframe.contentWindow.documentElement.scrollHeight; } var myHeight=Math.max(bodyHeight,scrollHeight); myframe.height=myHeight; }catch(ex){ console.log(ex); } } window.setTimeout("resizeIframe()",200); </script> </head> <body style="text-align: center"> <iframe id="myframe" src="iframe自适应高度_iframe.html" scrolling="no" frameborder="0" style="border:1px solid black;"></iframe> </body> </html>
demo_iframe自适应高度
最新推荐文章于 2019-07-19 10:55:00 发布