Page 1 of 1

Reading parent variable into iframe

Posted: Fri Dec 12, 2014 12:09 pm
by mrojek
I am currently working on a program that will require an iframe to read data from the display screen when the screen is loaded. So far I have had no luck reading in anything to the iframe. Here is a section of my javascript code for the iframe:

<p id="Var1"></p>
<p id="Var2"></p>
<script type="text/javascript">
document.getElementById("Var1").innerHTML = txtVar1;
document.getElementById("Var2").innerHTML = parent.document.getElementById(window.txtVar1);
</script>

These attempts that I have made in the javascript have not worked for me.
Is this even possible with using the profound iframe widget or am I not coding this correctly?
Any information you could give me would be great

Thanks

Re: Reading parent variable into iframe

Posted: Sat Dec 13, 2014 2:42 pm
by Scott Klement
Assuming your goal is to retrieve the contents of the textbox named 'txtVar1' in the parent frame, you could do that like this:

Code: Select all

var myVar = parent.pui.get("txtVar1");
The code that you provided as an example is using a Javascript variable named txtVar1 instead of looking for a DOM element with that name.

Re: Reading parent variable into iframe

Posted: Mon Dec 15, 2014 8:59 am
by mrojek
Scott,

Works perfectly! Thanks for the quick reply!