Posts

Showing posts with the label cross domain

Resizing Cross-Domain IFrame with Javascript

I tried to find a way to pass height of page loaded in an IFRAME to parent document in order to reset the height of the IFRAME with javascript. It's a simple coding, but .. if you use IFRAME with a page in a different domain, you cannot access to properties of page opened in IFRAME and from page to opener. The idea is to be able to pass the value of the height of the content at regular intervals, using a javascript function, and try to read it by the parent. This applies to the height value, but works for any data, of small size, to be passed client side from content of the iframe to container in a cross domain situation. Obviously, if we can access page open iframe in edit. NOTE: Both domains must be added to Trusted Sites. Let's see how. I put the following function in the page that I want to load iframe: setInterval (function () {this.frames.status = getHeight();}, 400); getHeight function () {      var height;     [we calculate body heig...