PDA

View Full Version : image target in different frames - help please


pavi
09-02-2002, 01:49 AM
Please could anyone help ?

I have a parent frameset page with 2 frames : "imgframe" and "controlframe"

In the imgframe is one image only, and the code
<img src="images/abc.jpg" name="imgspot" width="90" height="50">

I have a button in the controlframe. When clicked, I want to change the image in the imgframe.

I am trying to access it via :

parent.imgframe.document.images[0].src="images/newimg.jpg" or
parent.imgframe.document.imgspot.src="images/newimg.jpg"


but nothing is happening. (I also tried it without the "document." in there.)


I am sure it's a simple mistake but can't find previous posts which answer this.

adios
09-02-2002, 01:51 AM
Try an absolute URL in there.

pavi
09-02-2002, 02:30 AM
tried that too...still nothing happening.

I can change other properties from outside the frame without a problem, for example

parent.imgframe.document.bgColor=newcolor works fine, but

parent.imgframe.document.images.imgspot.src="images/anything.jpg" won't, nor will
parent.imgframe.document.images.imgspot.src="http://www.mysite.com/images/anything.jpg"


Targetting the image from within its own frame works fine too, either with absolute URLs or relative.

adios
09-02-2002, 02:43 AM
Quotes OK in your button script? Sounds like it.

<input type="button" onclick="parent.imgframe.document.imgspot.src='images/newimg.jpg'">

Try:

alert(parent); //[object]
alert(parent.imgframe); //[object]
alert(parent.imgframe.document); //[object]
alert(parent.imgframe.document.images); //[object]
alert(parent.imgframe.document.images.imgspot); //[object]