IFrame Resizer not resizing

时间:2015-07-28 23:48:57

标签: javascript jquery iframe-resizer

I'm working on this page here: http://factor1hosting.com/~dnaz/wordpress/certifications/

And I am trying to pull in a cross domain iframe.

I am using @DavidJBradshaw's iFrame Resizer to achieve this. However, I am not getting the iframe to work correctly.

I can use just the plain javascript init:

select dateadd('day', 3, current_timestamp);

And when I use this I do get the log but it does not resize. I've also tried the jQuery method:

<script>iFrameResize({log:true})</script>

And don't get the log or the iframe resized. I also tried wrapping it in a document ready and that doesn't achieve it either.

Anyone have any thoughts or ideas as to why this isn't firing correctly? My console isn't throwing any JS errors... Thanks!

EDIT: here is an example of how I am currently setup on the HTML side.

$('iframe').iFrameResize( [{log: true}] );

EDIT 2: Here is my console log when it does fire, and it's setting the iframe to 150px even though the content extends longer then that.

<iframe src="http://phpstack-9420-21004-48731.cloudwaysapps.com/onlinecert/certification/login" width="100%" scrolling="no"></iframe>
                <script>
                    jQuery(document).ready(function () {
                        jQuery('iframe').iFrameResize( [{log:true}] );
                    });
                </script>

1 个答案:

答案 0 :(得分:12)

知道了!

iframe体高度计算不正确,所以我改变了计算iframe高度的方式。我正在使用'lowestElement'来实现这一点并且效果很好。

iFrameResize({
    log                     : true,                  // Enable console logging
    enablePublicMethods     : true,                  // Enable methods within iframe hosted page
    heightCalculationMethod : 'lowestElement',
});

来自GitHub repo :lowerElement循环DOM中的每个元素并找到最低底点