image swap code help needed

Discussion in 'HTML & Website Design' started by madmn, May 25, 2006.

  1. #1
    I have a large picture on my homepage 3/4 of the way down and several smaller pictures around it which swap with the big one when clicked. Below is some of the code for the image swap. The problem is when they click on a picture to swap it it reloads the page at the top and they have to scroll back down to view it again. This makes it really inconvenient if the visitor wants to view all 8 pictures. Is there a way to make it reload at the same place after they click on a picture?

    <th height="80" scope="col"><a href="#" onclick="MM_changeProp('picture','','src','images/________.jpg','IMG')"><img src="images/thumbs/________.jpg" width="120" height="75" border="0" /></a></th>
    </tr>

    <th width="390" valign="top" scope="col"><img src="images/________.jpg" name="picture" width="390" height="251"/></th>



    Thank You​
     
    madmn, May 25, 2006 IP
  2. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's hard to tell for certain without seeing exactly what the script is doing, but what happens when you move the Javascript into the href and out of the event handler?

    <a href="javascript:MM_changeProp('picture','','src','images/________.jpg','IMG')">
     
    the_pm, May 26, 2006 IP
  3. madmn

    madmn Well-Known Member

    Messages:
    431
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    108
    #3
    That works perfectly, however it just enlarges the smaller thumbnail picture, which has terrible resolution when blow up. The original script used a separate larger photo for the swap. Any suggestions for this, here is a more accurate copy of the script:

    <th height="95" scope="col"><a href="#" onclick="MM_changeProp('picture','','src','images/largepicture.jpg','IMG')"><img src="images/thumbs/thesmallerpicture.jpg" width="120" height="90" border="0" /></a></th>

    Thank You
     
    madmn, May 26, 2006 IP
  4. the_pm

    the_pm Peon

    Messages:
    332
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #4
    All I did was move the function out of the event handler - I just rearranged the furniture a bit :) I didn't post the full code in my last post, just the part I changed. Maybe that was the problem. Here's exactly what you wrote above, but with the modification I made:

    <th height="95" scope="col"><a href="javascript:MM_changeProp('picture','','src','images/largepicture.jpg','IMG')"><img src="images/thumbs/thesmallerpicture.jpg" width="120" height="90" border="0" /></a></th>
     
    the_pm, May 27, 2006 IP
  5. madmn

    madmn Well-Known Member

    Messages:
    431
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    108
    #5
    Works perfectly,

    Thank you
     
    madmn, May 29, 2006 IP