Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Problem with javascript - IE, Netscape and Firefox

    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/ex...0&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:
    Code:
    //script:
    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?

    Thanks!!!
    Matt Tyree

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Try chaging the thumbnail link to:

    Code:
    <a href="/images/experiences/118-large.jpg" onClick="MM_swapImage(....); return false;">
    You also need to change this:

    jobpicurl.href=a[i+4];

    to:

    document.getElementById("jobpicurl").href=a[i+4];

  • #3
    Regular Coder Tyree's Avatar
    Join Date
    Sep 2003
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    You are the friggin' man!!! That did it!!!

    Thanks!!!!!!!...wait wait...THANKS!!!!!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •