1

I have a form built with Form Builder. I am showing the form in an iframe. How can I calculate the forms height so I can pass it to the iframe and as result have no vertical scroll bar on the iframe but only on the main window.

I tried calling this method on onload event of the iframe:

function setSize() {
    var iFrame = document.getElementById("myIframe");
    if (iFrame.contentDocument) {
      //FF 3.0.11, Opera 9.63, and Chrome
      iFrame.height = iFrame.contentDocument.documentElement.scrollHeight + 30; 
    } else {
      //IE6, IE7 and Chrome
      iFrame.height = iFrame.contentWindow.document.body.scrollHeight + 30;
    }
}

But this doesn't work because the content of the iframe isn't ready yet (if I call the method on button click everything works fine). Is their another way to achieve this? Is their an event when the form is fully initialized?

avernet
  • 30,895
  • 44
  • 126
  • 163
Faton
  • 853
  • 1
  • 9
  • 19

1 Answers1

1

The answer to this question doesn't need to depend on the particular technology used to generate the content if the iframe (Orbeon Forms in your case). So I would refer you to this other question and in particular this answer that uses jQuery.

Community
  • 1
  • 1
avernet
  • 30,895
  • 44
  • 126
  • 163
  • Thank you for answering, this worked fine form me : $('myIframe').load(function() { this.style.height = this.contentWindow.document.body.offsetHeight + 30 + 'px'; }); – Faton Nov 29 '11 at 13:02
  • Excellent, I am glad this helped. And the credit should got to @Tom who provided the answer using jQuery in that other thread. Could you mark this question as answered, by clicking on the 'v' to the left of the answer above? – avernet Nov 29 '11 at 17:41