JavaScript image swapping (Internet Explorer 5) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


JavaScript image swapping (Internet Explorer 5)

I've managed to come up with a JavaScript function which changes an image on another frame.

The odd bit is that I need to change the file in a particular frame before the picture is loaded.

This all works fine, but for some reason it needs me to add a message box before the image is displayed.

With the message box, it works fine - the frame changes, and the message box is displayed, when OK is pushed, the image is changed.

However, without the message box, the image doesn't change. I need to get rid of the message box, but at the same time I need the image to show. Someone told me it had something to do with the image trying to load before the right frame is loaded. I'm not sure it whether this is right or not. The wierd thing is that I don't get an error message when I remove the message box, which implies that its not trying to load the image earlier. The Javascript function I'm using is shown below. Any thoughts?

function change(name1, name2)


var banner;

var pImage;

var text;

if (parent.picframe.location.href="contactleft.htm")



var banner = eval(name1 + '.src');

var pImage = eval(name2 + '.src');

var text = eval(name1 + '.alt');


parent.topframe.banner.alt = (text);

parent.topframe.banner.src = (banner);

parent.picframe.image.src = (pImage);



Sign In or Register to comment.