PDA

View Full Version : targeting a layer in an iframe


stv
10-10-2002, 01:57 PM
Hello all

I am having major problems at the moment in targeting a layer that is within an iframe on an index page (no frames)

I want to be able to click a link on the main page that will then move a specific layer within the iframe

Any help much appreciated - i always have problems with my javascript targeting for some reason!!

Thanks
Steve

Mr J
10-10-2002, 02:30 PM
Something like



<a href="#null" onclick="document.iframename.document.all["layername"].style.pixelLeft="100"></a>




Possibly?

Mr J
10-10-2002, 02:32 PM
Sorry the above has typo's




<a href="#null" onclick="document.iframename.document.all['layername'].style.pixelLeft='100'"></a>



Haven't tried this, but might work

stv
10-10-2002, 02:42 PM
Mr J

thanks for the quick reply

it does work but only in ie - i am also trying to write it for NS6

In the final version i would also like the movement to be a smooth animated transition (but first things first!!)

regards
Steve

stv
10-10-2002, 03:34 PM
i am currently trying to get it to move by using this scrip;

document.showcase.document.getElementById('scroller').style.Left="100";

where showcase is the name of the iframe, and scroller the layer

It doesn't work!!

stv

ASAAKI
10-10-2002, 04:23 PM
just a guess

document.showcase.getElementById('scroller').style.Left="100";

ASAAKI
10-10-2002, 04:32 PM
okay that most prob didn't work.

try this, it isn't a straightforward way to do it but it oughta work:

in the iframe do:
<script>
var sc=document.getElementById("scroller")
</script>

then where u've got ur main script do:
top.frames["showcase"].sc.style.left = "100"

stv
10-10-2002, 04:39 PM
ah ha

asaaki - "if at first....." i have been trying this all day and finally i have it sussed (well nearly!)

frames['showcase'].document.getElementById('scroller').style.left = scrollleft+"px";

So i have a variable named "scrollleft" that holds the value of the scroller layers original left pos.
The targeting is right now but i cant seem to use the scrollleft value to relocate it after being dragged!!

Its just one after another!!

stv

stv
10-10-2002, 05:25 PM
finally got it - now to make the movement nice and smooth!!