0

I have an iframe and I am trying to resize it based on its actual content (like so I dont get any scrolling). I have tried the following:

alert(document.getElementById(iframe).contentWindow.document.body.height); alert(document.getElementById(iframe).contentWindow.document.body.scrollHeight); alert(document.getElementById(iframe).contentWindow.document.body.offsetHeight);

None of those work. iframe contains the id of the iframe. The last two lines work in Chrome.

Any help would be really appreciated.

Yannis
  • 6,047
  • 5
  • 43
  • 62
  • Are both documents on the same domain? – tomsv Sep 09 '12 at 08:57
  • Duplicate of this question? http://stackoverflow.com/questions/11806947/is-it-possible-that-iframe-resize-itself-without-help-from-main-window – Juffy Jan 17 '13 at 00:12

1 Answers1

0

I think you cannot access the properties of the document in the iframe from the outside document, but you can do it the other way: access the properties of the document in the iframe from within that document itself, and then call a function in the outside document. This outside function would then do the resizing, as described here: Resize iframe height according to content height in it

Community
  • 1
  • 1
tomsv
  • 7,207
  • 6
  • 55
  • 88