You are viewing limited content. For full access, please sign in.

Question

Question

Dynamically Adjusting the iFrame height

asked on March 4, 2014

I've made a form that has a few hidden field elements to it and have created the embed to get it on a page. 

 

Once embedded it creates an iFrame. However to get the iFrame to be the size I want, I have to create static height and width in order to get rid of the scrollbar (No scrolling="no" will not give me the desired effect either). The iFrame doesn't automatically size to content within the iFrame.

Unfortunately, making static height doesn't bode well for my design. I have to make the iFrames height larger than the form itself to accommodate for the hidden fields. Thus leaving a huge gap below the form, ruining the design of the rest of the page.

 

It would be ideal for the iFrame to automatically pick up the height of the content within the form when hidden fields are collapsed as well as when they are unhidden. 

 

In other words. When the fields are hidden the height of the form would automatically be 960px in height and the when they aren't hidden the iFrame would resize to 1060px in height.

 

I'm curious as to whether anyone has had this dilemma before and has create a solution that would solve the problem.

 

0 0

Answer

APPROVED ANSWER
replied on March 4, 2014

See this Stack Overflow question.  As noted in the comments there, you'll need a more complicated solution if the page and the iframe content come from different domains, since in that case browser security will keep scripts running in the page from accessing the content of the iframe.  The example only checks the size one time, if your content will change height dynamically you can run the code in a setInterval loop.

3 0

Replies

replied on March 4, 2014

Is the form on the same domain as the site that is embedding it?

0 0
replied on March 5, 2014

The form resides on a sub domain from where it's being embedded. We'll try it anyways and see what happens next.

Thanks guys!

0 0
replied on March 10, 2014

We're still trying but it doesn't seem to be working out so well due to the old security issue.

Is there anyway to embed the forms on another server without an iFrame? 

0 0
replied on March 10, 2014

There's not a way to embed forms without an iFrame at the moment. As long as the form and the parent page are in the same domain (sub-domain should also be fine), you should be able to accomplish what you're trying to do.

 

If you're on Forms 9.1, you can modify the embed code slightly to allow code on the parent page to run when the form loads. See this topic in the online help for more information. 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.