Is there a way to have the height of an iframe adjust on its own to fit just the content?
I'm thinking of embedding a form on a website with an iframe but I want it to just show the frame without any white space and without a scroll bar. Any ideas?
There is, it takes a bit of javascript and 'postman', if that doesn't sound daunting let me know, i can probably find a good tutorial.
Check this out:
https://javascriptbit.com/transfer-data-between-parent-window-and-iframe-postmessage-api/
You want this part: "2. Sending data from child iframe to parent window
:"
I'd recommend setting it up just like the demo first, to see it work, and then adjust for your use case. My suggestion is to have javascript inside the iframe detect the page height (and re calculate it on page resize, reload) and send that height to the parent via 'message'. Then the parent adjusts the height of the iframe to match.
We've done dynamic/responsive embeddable iframes like this for embeds across thousands of websites for years, its pretty bulletproof as long as you have control over the child completely, and whoever is installing the embed/iframe is okay with your small javascript snippet that runs on the parent. You might be both people in this case! Which would make it easy.
Thank you . I'm just seeing this now.
I will DM you the details to make sure it will work. Thank you