1 Reply Latest reply on Feb 4, 2010 9:19 AM by thedeancorp

    Is it possible to add a url/href to the MM_swapImage funtion?

    thedeancorp Level 1

      I have a bit of code I created in Dreamweaver CS3 about 3 years ago that I am revisiting/updating. It has a simple html picture gallery that uses the MM_swapImage function with the onclick command. Basically, there are a few thumbnails with a larger picture on the left. When a thumbnail is clicked, the larger image on the left changes. I'd love to add a link to the new larger image, but I can't think of a way to make this possible using this code. It isn't too important but if anyone has any ideas, I'd love to hear them.

       

      Here is the code:

       

      HEADER:

      function MM_findObj(n, d) { //v4.01
        var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
          d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
        if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
        for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
        if(!x && d.getElementById) x=d.getElementById(n); return x;
      }

      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];}
      }

       

      BODY:

      <img src="../images/THUMBNAIL.jpg" width="73" height="98" title="TITLE" onclick="MM_swapImage('li1','','../images/NEW_IMAGE.jpg',1)" />

       

      In that code, the 'li1' is the image that gets replaced and the 'NEW_IMAGE.jpg' is the one I'd like to have a url/href attached to.