Pass Javascript Variable to Iframe Src Link

I’m a bit new to JavaScript and have been searching for the answer for a couple hours before posting. I have a page that loads a form using an iframe. I have a Javascript function that parses the URL and saves the UTM values to variables.

Now I need to pass the variables to this iframe url.

<iframe id="ourIframe" onload="javascript:parent.scrollTo(0,0);" height="644" allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none" src=""></iframe>

The form is set up to accept paramters in the following format:

My javascript variables are “utm_campaign” and “utm_source” etc. So element_1_1 = utm_campaign

I hope this is pretty easy to do. I just can’t figure out how to get my variable into my URL of the iframe.



Are the iframe and your main page on the same domain?

What does this mean?
Are you trying to submit the form with a certain set of values?

Could you maybe make a runnable demo or link to a page where we can see this?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.