Click to See Complete Forum and Search --> : referencing contents of iframe


shumway
11-07-2003, 09:40 AM
Ive spent almost 20 hours on this now and I just cant figure it out.

I have this script containing several iframes. (I have simplified it and deleted all but one here.):

<html>
<head>
<script language="JavaScript1.1" type="text/javascript">
function WindowZoom( module )
{
// This doesnt work!!!
// document.getElementById( module ).document.getElementById('DivBorderBR').style.left = 100;


//But this works!!!
Games.document.getElementById('DivBorderBR').style.left = 100;


alert( document.getElementById( module ).id ); //Gives "Games"
alert( Games.id ); //Gives undefined
}
</script>
</head>

<body>
<iframe id="Games" style="position:absolute; left:200; top:200; width:600; height:400px; z-index:1; border:0px #FFFFFF" src="Games.htm" frameborder="1" scrolling="no"></iframe>
</body>
</html>


Games.htm looks like this:

<html>
<body>

<form method=post name="GamesForm" action="">

<img src="../../lib/images/DivGames.gif" class="DivHeader" onClick="parent.window.WindowZoom('Games')" style="position: absolute; left: 3; top: 120">

<img id="DivBorderTL" src="DivBorderTL.bmp" style="position: absolute; left: 0; top: 0;" width="109" height="109">
<img id="DivBorderTR" src="DivBorderTR.bmp" style="position: absolute; left: 396; top: 0;" width="109" height="109">
<img id="DivBorderBL" src="DivBorderBL.bmp" style="position: absolute; left: 0; top: 156;" width="109" height="109">
<img id="DivBorderBR" src="DivBorderBR.bmp" style="position: absolute; left: 396; top: 156;" width="109" height="109">

</form>
</body>
</html>




Pliiiiiiiiiiiiiiiiiiiiiiiiizzze somebody help me!!!!!!!!!!!!!!!!!!!

Why doesnt ...
document.getElementById( module ).document.getElementById('DivBorderBR').style.left = 100;

...work when...
Games.document.getElementById('DivBorderBR').style.left = 100;

...does?????

96turnerri
11-07-2003, 09:46 AM
thats a darn good question, in theory it should work

shumway
11-07-2003, 10:42 AM
96turnerri

That helps my ego but not my problem ;)

96turnerri
11-07-2003, 12:04 PM
sry didnt mena to bruise your ego :P

shumway
11-07-2003, 01:00 PM
I think you missunderstood me - I was glad that you thought it should work but sorry that you didnt give me any solution...

Isnt there anybody who can tell me what Im doing wrong??? Its such a simple problem....

Is there any other way of getting the Games iframe from the variable instead of getElementById??? or can I do it in some other way?

Pleeeeeease! :(

demo
11-07-2003, 01:12 PM
hey,

for a start replace this:

document.getElementById( module ).document.getElementById('DivBorderBR').style.left = 100;

with:

parent.frames(module).document.getElementById('DivBorderBR').style.left = 100;

i'll hav a look at the rest, what do you want?


demo

demo
11-07-2003, 01:15 PM
hey again,

one more thing:

Games.id doesn't work because Games is the id so you cant acces the id of the id because it doesnt make sense or work.

demo

shumway
11-07-2003, 01:22 PM
ok - well im a bit new to this so i thought

getElementById( 'Games' ).id
getElementById( module ).id
Games.id

would be the same thing.

What else do I want?
I want the world to be a better place.
I would like everyone to be happy and well.
I would like to be rich.

but for now im just happy you solved my problem :)

Thankyou so much demo!