Help with javascript to control iframe in wordpress

Hey Everyone,

I’m looking for a way to do some javascript on a form to control an iframe. I have a form that I am embedding into a wordpress page. This form is a 3 step form and I was wondering if anyone can help me with 2 things.

The first thing is adjusting the iframe height based on the content size of each form page and the second thing is to scroll to the top of the iframe onload so when the form is submitted (Step 1 to 2) it scrolls to the top of the iframe of the second page. I have tried to get this working for many hours this weekend and I can’t seem to get it to work. any input would be greatly appreciated.

Hey Cam!

On your WordPress site, please try adding the width and height styles to your iframe tag.

<iframe src="YOUR_URL" style="width: 100%; height: 100vh;"></iframe>

In the JavaScript section inside the Tadabase builder, please add the following to each page step where you would like the page to scroll to the top onload.

    document.body.scrollTop = 0;
    document.documentElement.scrollTop = 0;

Thanks for this Chem, Unfortunately neither of these solutions seem to work. tried it in Firefox and Chrome