title: script works only after refresh
body: <p>in the first page i have an image with a link that you can click on it:</p>
  
  <pre><code>&lt;div style="width: 97px; height: 130px;"&gt;
  &lt;a href="objects_lost.html?obj=images/dog.png"&gt;
  &lt;div&gt;
  &lt;img src="images/dog.png" alt="" style="width: 100%; height: 100%;"&gt;
  &lt;p style="color: black; margin-top: 0px;"&gt;DOG&lt;/p&gt;
  &lt;/div&gt;
  &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and when you click on it, opens a new page that shows the image you clicked. BUT IT ONLY WORKS AFTER ONE REFRESH. </p>
  
  <pre><code>    &lt;img src="" id="image"/&gt;        
      &lt;script type="text/javascript"&gt;
          function whatImg() {
              var str = getUrlVars()["obj"];
              document.getElementById('image').src = str;
          }
  
          function getUrlVars() {
              var vars = [], hash;
              var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');
              for(var i = 0; i &lt; hashes.length; i++)
                  {
                  hash = hashes[i].split('=');
                  vars.push(hash[0]);
                  vars[hash[0]] = hash[1];
                  }
              return vars;
              }
          whatImg();
      &lt;/script&gt; 
  </code></pre>
  
  <p>any help?
  I use JQuery Mobile</p>