我该如何实现自动化?我希望它可以将宽度/高度扩展到它所拥有的内容。什么决定了iframe的宽度和高度?
例如在这个小提琴中,它看起来随机制作一个300像素×200像素的盒子。
但内容实际上是约10页或8.5英寸(11×10)英寸。一页是8.5乘11英寸。我知道我可以通过简单地将它们设置在CSS中来设置维度,但我希望它们能够根据iframe的内容进行调整,即内容是动态的。
小提琴代码:
<div id="community">
<div id = "community_outer"></div>
<div id = "community_cover"></div>
<iframe scrolling="no" id="community_frame" src="https://docs.google.com/document/d/1n9bsHIBk1KxGQTKgUF-NG6FRhb4LP0OHfmd4I50CFCU/pub" ></iframe>
</div>
看看这个问题,有你的问题的解答:http://stackoverflow.com/questions/9162933/make-iframe-height-dynamic-based-on-content-inside-jquery- javascript – mattsoave
'iFrameID.height = iFrameID.contentWindow.document.body.scrollHeight +“px”' –
我想这也适用于宽度。不知道为什么浏览器不这样做对我来说。 –