davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.

Home Page:https://iframe-resizer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect height calculate?

indapublic opened this issue · comments

Hi! It's me again. I am integrated script (as you recommended), and script is working successfully. But I have problem with height calculating (it's very large iframe)
You can try

<iframe src="http://avia.make.travel" width="100%" scrolling="no"></iframe>
$('iframe').iFrameSizer({
contentWindowBodyMargin: 0,
doHeight: true,
doWidth: false,
interval: 32,
autoResize: true
});

After iframe loaded please click big blue button. Iframe will set height at 1776px around, but content is larger.

Strange, looks like mutationObserver stops working after the page goes past a certain size, or it gets throttled if called too many times in quick succession. This would appear to be a browser limitation.

Try turning on enablePublicMethods and then have the content page call window.parentIFrame.size() whenever it finishes adding in extra content to manually force the iFrame to trigger a resize event.

The other option would be to not make so many insertions in to the page at such a quickfire rate. I expect the browser kills the script, because it thinks you've created an endless loop.

Let me know if that fixes it for you.

Also what happens in a browers, such as IE8, that does not support mutation observer?

Lastly you only need to do.

$('iframe').iFrameSizer({
    contentWindowBodyMargin: 0,
});

As the other options are default values.

Also what happens in a browers, such as IE8, that does not support mutation observer?

I'm sorry. I don't have Windows right now and cannot check it.

Lastly you only need to do.

Hm, it not helps.

Did you try window.parentIFrame.size()?

Yeah, it can helps (and I did it successfully for another case three days ago), but extra height in this case is always dynamical

Can you not call it after each change to the page?

I'm sorry, I don't understood

Can you call window.parentIFrame.size() every time content gets added to the page?

No, I don't have this opportunity

OK, I have another idea, but need to checking in a new version.

At the moment the interval test only runs if mutation observer is not available, going to add option to force it to always run.

In the meantime you could try adding the following to your page.

setInterval(window.parentIFrame.size,33);

OK try the new 1.4.1 version with these options.

$('iframe').iFrameSizer({
    contentWindowBodyMargin: 0,
    interval: -33
});

Note the negative value on the interval option.

I'm tried - no difference.
You can view result on http://make.travel/ru/thailand/avia

Your iFrame has version 1.4.0 in it, try upgrading to v1.4.1 and then calling with.

$('iframe').iFrameSizer({
    contentWindowBodyMargin: 0,
    interval: -33
});

Why you decide it?

It have

<script type="text/javascript" src="http://make.travel/js/jquery/iframeResizer.contentWindow.min.js"></script>

and http://make.travel/js/jquery/iframeResizer.contentWindow.min.js output:

/*! iFrame Resizer (iframeSizer.contentWindow.min.js) - v1.4.1 - 2014-02-20

Seems the old version was getting cached in my browser. I've looked at this a bit more and it seems the issue is that on your page document.body.offsetHeight stops updating for some reason. Both my code and jQuery use this to get the height.

If the page never reduces in size, then you could look at changing the iframe script to use scrollHeight instead, but this value never reduces in size. So is not suitable for the main codebase.

Hope that helps.

I've added a new option called heightCalculationMethod which if set to 'scroll' should fix this for you.