Prevent picture loading

Discussion in 'JavaScript' started by dvdmovie29, Jan 7, 2007.

  1. #1
    I have the following script which swaps the picture when clicked:

    img1=new Image()
    img1.src="avatars/avatar1preview.gif"
    img2=new Image()
    img2.src="avatars/avatar1.gif"

    and i initially used the script so that avatar1.gif wont load unless clicked on. But, when you open the page it still loads (takes a long time). How can i make it so that the image only loads when clicked on. Below is what goes around the picture:

    <a onClick="document.images['avatar1'].src=img2.src" onMouseup="document.images['avatar1'].src=img1.src">
     
    dvdmovie29, Jan 7, 2007 IP