title: How to link different slideshow images with a URL in Javascript
body: <p>I am very new to JavaScript and I am creating a simple slideshow and I got it work ok. The only thing is I can't seem to create a web link to each of the images in my slideshow.  I would like for it to link to a different web page to the 4 different images I have for the slideshow as it scrolls though.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript"&gt;
  &lt;!--
  //preload images
  var image1=new Image()
  image1.src="Images/slideshow_1_home_2013.jpg"
  var image2=new Image()
  image2.src="Images/slideshow_2_home_2013.jpg"
  var image3=new Image()
  image3.src="Images/slideshow_3_home_2013.jpg"
  var image4=new Image()
  image4.src="Images/slideshow_4_home_2013.jpg"
  //--&gt;
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div align="left"&gt;&lt;img src="Images/slideshow_1_home_2013.jpg" 
   name="slide" width="974"  height="305" align="left"/&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
  &lt;!--
  var step=1
  var whichimage=1
  function slideit(){
  if (!document.images)
  return
  document.images.slide.src=eval("image"+step+".src")
  whichimage=step
  if (step&lt;4)
  step++
  else
  step=1
  setTimeout("slideit()",10000)
  }
  slideit()
  function slidelink(){
  if (whichimage==1)
  window.location="link1.htm"
  else if (whichimage==2)
  window.location="link2.htm"
  }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>