title: Javascript - Switching Between Two Images
body: <p>I have the following Javascript code which should rapidly switch between two images:</p>
  
  <pre><code>&lt;head runat="server"&gt;
      &lt;title&gt;Home Page&lt;/title&gt;
  
      &lt;script src="Resources/jQuery.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          function changeImage()
          {
              requestAnimationFrame(changeImage);
  
              var url = document.getElementById('Change_Image').src;
  
              if (url == 'Resources/Share1.bmp')
              {
                  document.getElementById('Change_Image').src = 'Resources/Share2.bmp';
              }
  
              else
              {
                  if (url == 'Resources/Share2.bmp')
                  {
                      document.getElementById('Change_Image').src = 'Resources/Share1.bmp';
                  }
              }
          }    
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;div&gt;
              &lt;h1&gt;Welcome to my Website&lt;/h1&gt;
              &lt;h2&gt;Below you can find an example of visual cryptography&lt;/h2&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;div&gt;&lt;img id="Change_Image" src="Resources/Share1.bmp" alt="Letter A" /&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Unfortunately, the code does not work and the image does not change to another one.  What am I doing wrong?  I am quite new to JavaScript so bear with me please?</p>