How to dynamically resize iFrame in Firefox?

2019-05-25 01:18发布

I used the solution stated on this page to resize the iFrame depending on the content:

Resizing an iframe based on content

And it works perfectly, except in Firefox. In Firefox, the other content is cut-off but once you keep on refreshing the page, the browser will slowly reveal the rest of the content. I saw someone replied that this is the solution to the problem:

Use jQuery to get the body height in framed.html (FF issue, body kept growing): var height = $(document.body).height();

However, I don't know where to put that line of code. Do I insert it somewhere within the 3 snippets of scripts on the original solution? If so, where do I put it?

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-05-25 01:34

In www.bar.net/framed.html: Use jQuery to get the body height in framed.html (FF issue, body kept growing):

change following code

// What's the page height?
     var height = document.body.scrollHeight;

with

var height = $(document.body).height(); 
查看更多
看我几分像从前
3楼-- · 2019-05-25 01:37

I already solved it. In case somebody else might be encountering the same problem, I used the code on the web page below which is slightly different from the link I gave above:

http://solidgone.org/Set-IFRAME-height-based-on-size-of-remotely-loaded-content

查看更多
登录 后发表回答