question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

iframe height not adjusted when clicking on link inside of iframe

See original GitHub issue

I’m using iFrame Resizer to embed a cross domain iframe on a page. This works well, until I click on a link inside of the iframe that takes me to the next page.

In the iframe source page (the remote one) I’ve got the following code in the header:

<script src="https://cdn.jsdelivr.net/npm/iframe-resizer@3.6.1/js/iframeResizer.contentWindow.min.js"></script>

In the page that’s embedding the iframe I’ve got:

<iframe id="crelate-iframe" src="https://foo.bar" frameborder="0" width="100%" scrolling="no">
</iframe>

and in the footer of the page:

<script type='text/javascript' src='https://cdn.jsdelivr.net/npm/iframe-resizer@3.6.1/js/iframeResizer.min.js?ver=1'></script>

<script>
(function($) {
    $(function() {
        $('#crelate-iframe').iFrameResize({
            log: true,
            heightCalculationMethod: 'lowestElement'
        });
    });
})(jQuery);
</script>

The logging doesn’t give away much as far as I can tell. I can only see it initially adjusts the height of the iframe, but when I click through it doesn’t and when the next page’s height is smaller I end up with a bunch of white-space at the bottom.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
MattOpencommented, Jul 24, 2018

Please have a look at parent div and all DOM elements inside iFrame that might not shrink themselfe I was facing same behavior but was able to remove it with html, body, .body{ min-height:0; }

0reactions
davidjbradshawcommented, Nov 16, 2019

If you have the script on every page, down sizing problems are always down to CSS

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can not adjust the iframes height - Stack Overflow
Basically all the elements whose display is "block" will expand itself horizontally all it cans, but will set its height to whatever it...
Read more >
How to adjust the width and height of iframe to fit with content ...
Another way set the height and width of the iframe to fit with content is to use resize property of CSS, this method...
Read more >
Automatically Adjust iFrame Height According to its Contents ...
You can use the JavaScript contentWindow property to make an iFrame automatically adjust its height according to the contents inside it, so that...
Read more >
3 Ways to Resize iFrames in HTML - wikiHow
1. Open up your HTML file. HTML files have a the file extension ".html" or ".htm" after the file name. You can edit...
Read more >
From object to iframe — other embedding technologies
<iframe> s are for embedding other web pages, and the other two allow you to ... This provides a way to embed an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found