将iFrame高度调整为内容高度
我正在加载一个跨网站的iFrame网站。 我想调整iFrame的大小以匹配我正在加载的网站的高度。 Sniply正是这样做,我想模仿function。 任何人都知道他们在这里执行什么样的巫术?
http://snip.ly/Z9nv#https://forums.eveonline.com/default.aspx?g=posts&m=5009807
看起来他们不仅从跨域站点访问文档,而且还使用不同的协议(HTTP / HTTPS)。 任何见解? 看起来他们可能会将iFrame的高度设置为某个不可能的高值,并在某种程度上停止了滚动。 帮帮我!
编辑:一些额外的细节..我在后端使用一些插件做我想提交的URL的一些分析: https : //github.com/mikeal/request和https://github.com/ tmpvar / jsdom 。 有没有要求我可以使用这两个插件之一,让我得到的文件的高度?
编辑2:我不想在iframe中滚动 – 我希望它匹配它包含的文档的高度。
我认为你必须设置CSS。 如果有更多的iframe,你可以使用一个类。
iframe { position: absolute; left: 0; right: 0; top: 0; bottom: 0; border: 0; height: 100%; min-width: 100%; width: 10px; -webkit-overflow-scrolling: touch; overflow: scroll; }
您必须将自己的元素设置为position:fixed
。
设置CSS这似乎工作
iframe { position: absolute; left: 0; right: 0; top: 0; bottom: 0; border: 0; height: 100%; min-width: 100%; width: 10px; }
这是一个现场示例
iframe { position: absolute; left: 0; right: 0; top: 0; bottom: 0; border: 0; height: 100%; min-width: 100%; width: 10px; }
<div>test</div> <iframe src="https://slashdot.org"></iframe>