Call JScript Function in iFrame - FireFox Issue

C

cont

Hi I have the following simple page:

<HTML>
<TITLE>Test</TITLE>
<HEAD>
<script language="javascript">
function doSubmit()
{
alert('test');
window.frames.item(0).updateParent();
}
</script>
</HEAD>

<body>
<table cellpadding="1" cellspacing="1" >
<tr>
<td rowspan="24" valign="top">
<IFRAME id="iTreeView" name='tree' src="iFrame_Child.htm"
width="324" height="550" scrolling="auto" frameborder="1"
marginheight=2 marginwidth=2 ></IFRAME>
</td>
</tr>
</table>
<table>
<form action="" method="POST" name="frmRequest">
<tr>
<td align=center><input type="button" OnClick="javascript:doSubmit"
value="Submit It"></td>
</tr>
</table>
</form>
</BODY>
</HTML>

<!----------------------------Respective Child
Page--------------------------------->

<html>
<head>
<title>iFrame Test</title>
<script>
function updateParent()
{
alert('In updateParent');
}
</script>
</head>
<body onload=updateParent()>
</body>
</html>


When the page loads, the updateParent function fires off (w/in iFrame),
but the button click event doesn't fire the function off. What am I
doing wrong?

This works fine in IE, but not in FireFox. I am using IE7 Beta 3 and
FireFox 1.5.0.6

Thanks in advance for any input!
 
M

Martin Honnen

window.frames.item(0).updateParent();

The frames collection is underspecified and dating back from DOM Level
0, it does not have an item method, at least not in Mozilla/Firefox.
Simply use
window.frames[0].updateParent();
or
window.frames.tree.updateParent();

<IFRAME id="iTreeView" name='tree' src="iFrame_Child.htm"
width="324" height="550" scrolling="auto" frameborder="1"
marginheight=2 marginwidth=2 ></IFRAME>

<td align=center><input type="button" OnClick="javascript:doSubmit"
value="Submit It"></td>

<input type="button" onclick="doSubmit();"
 
C

Coness

OMG - what a simple fix. You RULE!!!!!!!!!!!!!!! Thank you very
much!!!!!!!!!!!!!!!!!!!!!!!
Martin said:
window.frames.item(0).updateParent();

The frames collection is underspecified and dating back from DOM Level
0, it does not have an item method, at least not in Mozilla/Firefox.
Simply use
window.frames[0].updateParent();
or
window.frames.tree.updateParent();

<IFRAME id="iTreeView" name='tree' src="iFrame_Child.htm"
width="324" height="550" scrolling="auto" frameborder="1"
marginheight=2 marginwidth=2 ></IFRAME>

<td align=center><input type="button" OnClick="javascript:doSubmit"
value="Submit It"></td>

<input type="button" onclick="doSubmit();"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top