admin管理员组

文章数量:1318563

I have an external domain 'domainB' that I am pulling content from. Included in domainB's scripts is iframeResizer.contentWindow.min.js

My domain 'domainA' includes iframeResizer.min.js and I am calling it like:

$('iframe').iFrameResize({log:true, checkOrigin:false,
heightCalculationMethod:"taggedElement"});

No matter what I change the 'heightCalculationMethod' to, it doesn't have any affect on the iframe's height. Below is the logging

[iFrameSizer][Host page: iFrameResizer0] Added missing iframe ID: iFrameResizer0 (http://domainB/) iframeResizer.min.js:8
[iFrameSizer][Host page: iFrameResizer0] IFrame scrolling disabled for iFrameResizer0 iframeResizer.min.js:8
[iFrameSizer][Host page: iFrameResizer0] [init] Sending msg to iframe[iFrameResizer0] (iFrameResizer0:8:false:true:32:true:true:null:taggedElement:null:null:0:false:parent:scroll) targetOrigin: * iframeResizer.min.js:8
[iFrameSizer][Host page: iFrameResizer0] [iFrame.onload] Sending msg to iframe[iFrameResizer0] (iFrameResizer0:8:false:true:32:true:true:null:taggedElement:null:null:0:false:parent:scroll) targetOrigin: *

So it appears it is working, there are no errors, but it is having no effect. Is there a better way to do this, one that would actually change the height of the iframe?

I have an external domain 'domainB' that I am pulling content from. Included in domainB's scripts is iframeResizer.contentWindow.min.js

My domain 'domainA' includes iframeResizer.min.js and I am calling it like:

$('iframe').iFrameResize({log:true, checkOrigin:false,
heightCalculationMethod:"taggedElement"});

No matter what I change the 'heightCalculationMethod' to, it doesn't have any affect on the iframe's height. Below is the logging

[iFrameSizer][Host page: iFrameResizer0] Added missing iframe ID: iFrameResizer0 (http://domainB/) iframeResizer.min.js:8
[iFrameSizer][Host page: iFrameResizer0] IFrame scrolling disabled for iFrameResizer0 iframeResizer.min.js:8
[iFrameSizer][Host page: iFrameResizer0] [init] Sending msg to iframe[iFrameResizer0] (iFrameResizer0:8:false:true:32:true:true:null:taggedElement:null:null:0:false:parent:scroll) targetOrigin: * iframeResizer.min.js:8
[iFrameSizer][Host page: iFrameResizer0] [iFrame.onload] Sending msg to iframe[iFrameResizer0] (iFrameResizer0:8:false:true:32:true:true:null:taggedElement:null:null:0:false:parent:scroll) targetOrigin: *

So it appears it is working, there are no errors, but it is having no effect. Is there a better way to do this, one that would actually change the height of the iframe?

Share Improve this question edited Dec 19, 2016 at 15:56 Kevin Kloet 1,0861 gold badge11 silver badges21 bronze badges asked Dec 19, 2016 at 15:34 Dirty Bird DesignDirty Bird Design 5,55313 gold badges67 silver badges127 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

I had the same issue. In my case this was because in the page within the frame (the page with iframeResizer.contentWindow.min.js) there is an external plugin which sets this CSS style:

body,html{height:100%}

I fixed it by adding this CSS in the page within the frame:

 body, html {height:inherit !important;}

I was having the exact same issue as you (same settings and all), and realized that I did not have iframeResizer.contentWindow.min.js included correctly on my 'domaindB'

Once I made sure it was included, it worked - and a much longer list of logs was being printed.

Like you, I was under the assumption that because the initial short list of logs (that you quoted) were being printed, the two pages were municating; however, this is not true.

If you have sourceMaps enabled, you should see logs ing from iframeResizer.contentWindow.min.js

like this:

iframeResizer.contentWindow.js:150[iFrameSizer][iFrameResizer0] Initialising iFrame (http://domainB.site) iframeResizer.contentWindow.js:150[iFrameSizer][iFrameResizer0] TargetOrigin for parent set to: * iframeResizer.contentWindow.js:150[iFrameSizer][iFrameResizer0] height calculation method set to "taggedElement" etc etc.

If that is all you are seeing in the log, then the script isn't being loaded into domain B, or some other JS code on domain B is crashing and stopping this JS from running.

本文标签: javascriptiFrameResizer not calculating height of iframeStack Overflow