Click to See Complete Forum and Search --> : moving an image within an iframe


shumway
11-04-2003, 07:28 AM
Hi.

Im having problems accessing an image within an iframe. I guess its really easy but I cant get it to work. This is how my script lookes like (I have simplified it a lot - you can find the real thing on www.battlesite.com/henrik/battlesite2 - just login without username and password and its there.)

Anybody know of a good way to make it easier to find objects in the dom? - like my image here for instance.

Thankyou!





<html>
<head>

<script language="JavaScript1.1" type="text/javascript">

function MoveImage( )
{
//This is the row that doesnt work!!!!!!!!!!!
document.all['Games'].iframe.document.all['DivBorderTR'].style.left = 100;
}
</script>
</head>

<body background="../lib/images/backgrounds/matrix.bmp">

<iframe id="Games" style="position:absolute; left:293; top:5; width:112; height:124px; z-index:1; border:0px #FFFFFF" src="../Mod/Games/Games.htm" frameborder="0" scrolling="no"></iframe>

</body>
</html>



Games.htm lokes like this:
<html>
<body>
<img id="DivBorderTR" src="../../lib/images/backgrounds/DivBorderTR.bmp" style="position: absolute; left: 444; top: 0;" width="109" height="109">

<form method=post name=Games action="">
</form>

</body>
</html>

Shampie
11-04-2003, 08:09 AM
What is the name of the iframe?
<iframe id=framename src=...>

parent.framename.document.all['DivBorderTR'].style.left = 100;

and if you wish to change something on the page but from within the iframe it will be this.parent.form.object

I hope that helps!

shumway
11-04-2003, 10:33 AM
this.Games.document.all['DivBorderTR'].style.left = 100;

works great.

parent.Games... dont - but who cares ;)

But now I got a new problem - I dont have the name of the iframe (its a general function for moving iframes and pictures in them), only the variable $module containing the name of the iframe. So how do I do then?

this.$module.document.all['DivBorderTR'].style.left = 100;

doesnt work. Neither does:

this.getElementById($module).document.all['DivBorderTR'].style.left = 100;

so now im lost again...