-
-
Notifications
You must be signed in to change notification settings - Fork 972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iframe height sometimes sets to zero on initial page load #629
Comments
Try setting |
@davidjbradshaw It did not; I was still able to trigger the bug with |
Is this only happening in IE? And if so what version? |
Looking at the code. Try changing
|
Using Chromium 68.0.3440.106; not IE. Making that change does not fix the issue. |
Very strange and I'm a bit out of ideas. If you use a different resize method that would help. |
Thanks, @davidjbradshaw. I switched back to the default You can close this issue if you think there's no reason to dig into this further. |
@bontibon @davidjbradshaw , we had to revert to heightCalculationMethod: 'max' because it was cutting off many iframes. max is still sometimes setting the iframe height to zero, which is better than always having pages cut. Doing some debugging, and struggling to figure out why messageData is being set as follows: {iframe: iframe#iFrameResizer0.addon-iframe, height: 0, width: 0, type: "init"} note the missing id attribute. With logging turned on, you can see that the resetPage an event is received setting messageData to: {iframe: iframe#iFrameResizer0.addon-iframe, id: "iFrameResizer0", height: "560", width: "1400", type: "resetPage"}
But then you can see we get to a point where messageData is set to {iframe: iframe#iFrameResizer0.addon-iframe, height: 0, width: 0, type: "init"} However no new event was raised. For that matter, throughout the entire lifespan, messageData (which looks to me to only be set once here: https://github.com/davidjbradshaw/iframe-resizer/blob/master/src/iframeResizer.js#L510) is never set to an object missing the id attribute:
@davidjbradshaw can you point out anywhere in the code where messageData might have |
This doesn't seem like the right solution, but skipping settings dimension when messageData.id is absent, solves the problem. function setDimension(dimension) {
if (!messageData.id) {
log(
'undefined',
'messageData id not set'
);
return;
}
messageData.iframe.style[dimension] = messageData[dimension] + 'px';
log(
messageData.id,
'IFrame (' + iframeId +
') ' + dimension +
' set to ' + messageData[dimension] + 'px'
);
} |
That's very strange, do you want to make a PR for that? Testing for the error is better then having this problem, even if it is not a full solution |
I'm getting this now with Sometimes it doesn't (see the tiny black square): Resizing the window makes the iframe correct its size. The site is
It's intermittent, but I seem to get the zero-size-iframe situation a lot when I reload the page multiple times. Almost as if it were MORE likely when the iframe contents are in the cache. |
I am facing the exactly same issue. It doesn't resize correctly sometimes on page load, though clicking on the iframe content resize it correctly again. Did anyone found a solution? |
I think this is happening when the iframe container is hidden. The resizer returns 0px when the iframe is hidden. Check the following link and look into console |
Arh yes I have seen that happen before.
D.
--
Sent from my iPhone.
|
@davidjbradshaw Do you think is there any way we can get the correct height of the iframe even if the parent container is hidden? |
I can see this message in log "Hidden iFrame detected, creating visibility listener". It means the script is detecting the hidden iframe but visibility listener is not working. |
This should be fixed as of v4.2.3, thanks to PR #768 |
I came across this issue when placing the iframe in a bootstrap tab that wasn't active. When the user clicked on the tab that contained the iframe, the iframe content would not display in full and the logs showed iframe-resizer was setting the height at only 16px. To resolve this, I called the resize method in a tab onclick event handler. That got the iframe to render its size based on its content. |
Version: 3.5.15
Sometimes when the parent page is loaded, the height of the iframe is set to 0. Clicking on the page or switching tabs will re-trigger the calculation and set the height correctly.
I cannot reproduce this issue consistently. I simply mash the refresh button and it will eventually trigger.
iFrameResize configuration:
Log from a load with the iframe sized correctly:
Log from a load with the iframe sized incorrectly:
The text was updated successfully, but these errors were encountered: