Check my script?

Discussion in 'JavaScript' started by davidcarlson, Mar 10, 2009.

  1. #1
    My intent is to have a default image in my web page replaced by "image1" when image1's thumbnail is clicked.



    I have the following in the <head> tag of my page:
    <script language="Javascript" type="text/javascript">
      var im = new image();
      im.src = 'image1.jpg';
    </script>
    Code (markup):
    In the body of my page:
    onMouseDown="document.images.Pic.src=im.src"
    Code (markup):
    This code is in a <span> tag which spans the thumbnail to be clicked. (note : in the <img> tag of the picture to be replaced, I have name="Pic")

    For some reason, the picture doesn't load. Does anyone have any ideas? Thanks a lot
     
    davidcarlson, Mar 10, 2009 IP
  2. DGK

    DGK Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:
    onMouseDown="document.getElementById('pic').src = im.src;"

    In your HTML code: <img id="pic" src="...." />
     
    DGK, Mar 10, 2009 IP
  3. davidcarlson

    davidcarlson Guest

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oh haha actually "image" had to be capitalized. Problem solved. thanks though
     
    davidcarlson, Mar 11, 2009 IP