How to get iframe contentWindow height in cross domain

I want to automatically adjust the height of the iframe according to their content, but in the same domain it works correctly with contentWindow.height, but in the case of a cross domain its permission is denied to access the iframe dom.

+4
source share
1 answer

For modern browsers, you can use the window.postMessage function to communicate between iFrames belonging to two different domains.

There are also several jQuery plugins that wrap window.postMessage with older URL hashing methods for browsers that do not support window.postMessage . This makes the use of technology transparent to the end user.

You can see the following page (and possibly take the javascript you need):

Lutron - Ballast Selection Tool

A tool with drop-down lists is actually loaded from a separate domain into an iFrame. Then the iFrame dynamically changes depending on the height of the internal content.

+3
source

All Articles