title: html/javascript: using a variable as url for <a href>
body: <p>I developed a html page with a bit of javascript.
  I have several  tags and after clicking a link one of them is dynamically assigned a background image. This url is stored in a global variable. So far so good.</p>
  
  <pre><code>var picture,thumb
  
  function changeDivs(p)
  {
       if (p!='') {
          picture = './images/p'+p+'.jpg'; // global url variable
          thumb = './thumbs/p'+p+'.jpg'; // global url variable
          var pic = "url("+thumb+")";
          document.getElementById("poster").style.backgroundImage = pic;
          }
  }
  </code></pre>
  
  <p>I call the function like this:</p>
  
  <pre><code>&lt;a href="javascript:changeDivs('2')"&gt;Link&lt;/a&gt;
  </code></pre>
  
  <p>Now I want to make use of a thumbnailviewer script which needs to be accessed like this:</p>
  
  <pre><code>&lt;a href="javascript: global variable" rel="thumbnail"&gt; &lt;!-- Of course this "javascript: global variable" should be a valid url: the stored 'picture' variable --&gt;
          &lt;div id="poster"&gt; 
          &lt;/div&gt;
      &lt;/a&gt;
  </code></pre>
  
  <p>So I have stored the url in variable: picture</p>
  
  <p>How can I access the thumbnailviewer script through <code>&lt;a href&gt;</code> AND use the variable. I don't know if the thumbnail script can be called through a function or how.</p>
  
  <p>Thanks a lot!</p>