View Full Version : if(doc.images[0]==doc.images[i]) ???

04-08-2003, 06:41 AM
I am trying to use document.images[] to compare images to see if they are the same as follows:

for (i=1;i<=3;i++) {

This isn't working and when I test it with:

alert("Image[0]= " + document.images[0].src + " and image " + i + " = " + document.images[i])

the test returns the proper image file name for what ever is on the left side of the conditional expression (==), but won't return the file of the image to the right. It just says that it is an [object].

I suppose that I could use some string functions like:

IMG= document.images[0].src;
IMGi= document.images[i].src;
(IMG.substring(0) if(IMG!=IMGi)

But I'm thinkin' there's a better way. Any suggestions??

thanks, BDT

04-08-2003, 06:44 AM

You only put src on one side. Maybe thats your prob.

04-08-2003, 02:45 PM
Doh!!! How can I look at something for so long and still not see it? I knew it would be simple, but didnt' think it would be THAT simple.


04-08-2003, 08:23 PM
Expect it to happen again. The more you look at a script the more it merges together. I've done things like that all the time.