Click to See Complete Forum and Search --> : undefined error when printing to id tag in another frame


andrew1234
09-05-2003, 08:13 AM
my frames page is like this

<html>
<frameset rows="*,80" frameborder="NO" border="0" framespacing="0">
<frame src="1 .htm" name="top" id="top">
<frame src="2.htm" name="bot" scrolling="NO" noresize id="bot">
</frameset>
</html>
---------------------------------------------------

--------------------------------------------
the htm page that loads into "top" frame is

<html>
<
<body ONLOAD = "top.bot.document.getElementById('fred').firstChild.data = 'Hello, World!'">

</body>
</html>

--------------------------------------------
the htm page that loads into "bot" frame is


<html>

<body>

<div id="fred">dd</div>
</body>
</html>


--------------------------------------------------------
when the to frame load is tells the botton html pages id tag fred to say hello world

but it won't work

it say underfined error

any ideas woul be a gret help


thanks

Andrew

Webskater
09-05-2003, 08:51 AM
I'm no expert but as no-one else has answered you ...

fred does not have a firstChild
fred is a div tag with nothing in it except two characters
you would say fred.innerText =

I don't know if your frame reference would work. I would say

window.parent.frames('bot').fred.innerText = 'Hello World'

andrew1234
09-05-2003, 10:41 AM
thanks

it worked

what would i use child for?

thanks

andrew

Webskater
09-05-2003, 10:58 AM
if you have an object in a div tag or perhaps in a cell in a table - the object is the firstChild. So if you have a text box in a div tag and you wanted to set the value of the textbox you would use
nameofdivtag.firstChild.value = 'Hi de hi'