How to dynamically resize iFrame in Firefox?

2019-05-25 01:27发布

问题:

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?

回答1:

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(); 


回答2:

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