View Full Version : Problem with javascript - IE, Netscape and Firefox

07-08-2005, 02:21 PM
I'm hoping someone can help me with this. I have a friend who runs circles around me as far as javascript goes and he can't figure it out either.

Here's the problem:
I'm using Dreamweaver which has a simple Swap Image script. That script works fine in all 3 of the browsers I mentioned. However, I wanted the script to do one more thing other than swap and image. Here's a link so you can see what I mean: http://www.craddockcunningham.com/experience_project.php?ID=50&categoryID=1

See those three images at the bottom right. Well, when you click those the larger image above them should change. This works great in Firefox. However, in IE the image doesn't change.
I think it is because of the additional line added to Dreamweaver's script. Here's a snippet of the script and then the implementation lines within the body of the page:
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
if(a.length==5) jobpicurl.href=a[i+4];}

//intermediate image code:
<a href="/images/experiences/118-fullsize.jpg" target="_blank" name="jobpicurl" id="jobpicurl"> <img src="/images/experiences/118-large.jpg" alt="Click for Larger Image" name="jobpicph" width="225" height="200" border="0" id="jobpicph"></a>

//thumbnail code:
<a href="javascript:;" onClick="MM_swapImage('jobpicph','','/images/experiences/118-large.jpg',1,'/images/experiences/118-fullsize.jpg')"><img
src="/images/experiences/118-thumbnail.jpg" alt="Image 1" name="jp01" width="50" height="44" border="0" id="jp01"></a>To add a little more complexity...I also wanted to make the href for the larger image change so that you could click it and see an even larger image in a new window. The last line in the script was added to check to see if the swapImage arguments equaled 5 which would mean I was supplying the link for the full sized image. If so, it changes the href "jobpicurl" to the url indicated in the argument for the function call under the thumbnail code.

So, here's how the 3 browsers shape up:
IE - the intermediate image does not display when you click the thumbnails. However, if you click where the image SHOULD be, then the correct full size image does come up in the new window.
Netscape 7 - Intermediate image changes but the link to the full size image always goes to the first image. It doesn't change with the intermediate image. Netscape 8, since it is built on Firefox works fine in both respects.
Firefox - Works flawlessly!

So, there's my problem. Can anyone have a peek at this and tell me something to try?

Matt Tyree

07-08-2005, 02:44 PM
Try chaging the thumbnail link to:

<a href="/images/experiences/118-large.jpg" onClick="MM_swapImage(....); return false;">

You also need to change this:




07-08-2005, 02:59 PM
You are the friggin' man!!! That did it!!!

Thanks!!!!!!!...wait wait...THANKS!!!!!!! :D