Resizing iframe with injected iframeResizer.contentWindow.min.js
See original GitHub issueHi,
I’m trying to resize a iframe which holds a static html page, but I don’t want to modify the page by hand.
So, I’m injecting the contentWindow.js by jQuery:
$(function () {
// ...
(function () {
const $iframe= $('.iframe');
if ($iframe.length <= 0) {
return;
}
$iframe.contents().find("head, body, div").first().append("<script src='https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/3.6.0/iframeResizer.contentWindow.min.js'></script>");
$iframe.iFrameResize([{log: true}]);
})();
// ...
});
However, the only output I get in the browser console is:
iframeResizer.js:132 [iFrameSizer][Host page: iFrameResizer0] IFrame has not responded within 5 seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ingored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning.
So it seems that the contentWindow.js does not load correctly? Do I have to send some event?
PS: The script is injected correctly:
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
iFrame Resizer - GitHub Pages
The package contains two minified JavaScript files in the js folder. The first (iframeResizer.min.js) is for the page hosting the iFrames. It can...
Read more >Resizing an iframe based on content - Stack Overflow
How do I resize the iframes to fit the height of the iframes' content? I've tried to decipher the javascript Google uses but...
Read more >Include iframe resizer inside embedded iframes | Community
On your side, this would only mean injecting the iframeResizer.contentWindow.min.js file in each report, and specify in your doc that the ...
Read more >iframe-resizer | Yarn - Package Manager
Keep same and cross domain iFrames sized to their content with support for ... v4.3.2 #936 Allow max/min values for iFrame size to...
Read more >How do I make my iframe resize to its content? - Wyng
The iframe resizer code enables your iframed campaign to automatically resize to the height and width of both ... contentWindow.min.js'; firstScriptTag.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, I think I found the answer:
https://stackoverflow.com/a/9777536
If I load the content from the .js file and inject it like
, it works.
Glad you found a solution and I might build that in one day.