Jump to content

iFrames and JavaScript


geudrik

Recommended Posts

I have an iFrame setup that looks like...

<iframe name="contentFrame" width="720px" src="http://10.209.91.30:4110/web2e" frameborder="0" scrolling="auto" marginwidth="0" marginheight="0" height="400px" class="frameclass"></iframe>

 

In this iFrame, I have a javascript variable that is set and reset every time the page is loaded/reloaded...

<script type="text/javascript">
var FormNameVariable="10008001";
</script>

 

In my parent frame, I need to either reference directly, or re-create the variable to be equal to what ever that var is set to in the iFrame.  I am trying...

var GetFormName = window.contentFrame.FormNameVariable;

 

I also have a function to spit out what ever that variable is..

function writeformname()
{
document.write(GetFormName);
}

 

In the parent frame (which, by the way isn't a frame - the iFrame is nested within a single HTML file) when I call that function, I get 'Undefined'.

 

What purpose of doing this, setting the variable and referencing it, is so that I can click a button from the parent window, and have it submit (click a button) within the iFrame.  I am using the following code for this...

<input name="_KEN" type="submit" value="Enter" id="_KEN" class="submenu_special" onclick="javascript:parent.contentFrame.document.GetFormName._KEN.click()" />

 

Where am I going wrong?

 

Note: The buttons in the iFrame are named, in this case, the above button code should be "Clicking" the button with the name of _KEN (yes, this button does exist)

 

Lastly, on occasion, the form name in the iFrame changes - each time the iFrame is refreshed, the variable I am setting is also refreshed.  So, is there a way to continually keep the variable in the parent window updated?

Link to comment
https://forums.phpfreaks.com/topic/172742-iframes-and-javascript/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.