Auto-size iframe cross domain

I am creating a web widget using iframe and javascript, and I would like to make my iframe resizable by its contents (which is loaded from another domain).

I did some searching (inclusive here in StackOverflow), and I find a couple of topics, but I could not find any conclusions about this problem.

Is it possible or not?

Since atm I need to set the iframe height to the maximum height of the content, which in some steps of my widget gives a lot of white space at the bottom, which doesn't look very good.

Please note that all interactions inside the iframe widget are done entirely with ajax. (Iframe src is just one html page).

+3
source share
2 answers

Take a look at this :) You can also use postMessage - there is a jBuery plugin for cross-browser.

+2
source

Manual coding of postMessage material is a walk in the park. You do not need a framework to do this for you. Here is a simple example in stackoverflow: cross-domain iframe resizing?

+2
source

Source: https://habr.com/ru/post/1770089/


All Articles