I am trying to get the height of a iframe hosted on a different HTTPS domain, with the following code:
var iframeHeight = document.querySelectorAll("iframe-widget__window").clientHeight;
iframeHeight.height = iframeHeight.contentWindow.document.body.scrollHeight + "px";
However I get the following error: Uncaught TypeError: Cannot read property 'contentWindow' of undefined
I have tried to check other questions on stackoverflow and many people are talking about wrapping the functionality in an load function, but that does not seem to work either. Even if I let the page finish loading completely and use the code in the console I still get the error.
Could it perhaps be Same-origin policy issues?