title: JAVASCRIPT: how to get the URL of a link in a page?
body: <p>how to get the URL of a link in a page?</p>
  
  <p>how to get current src of an iframe?</p>
  
  <p>What I want to do is add a special background color for a link in my page if the link's URL is the same as the src in the iframe.</p>
  
  <p>That is, when you click the link, it targets the iframe (changing its src of course). I want the link's background color to change. I also want it to change back when I click the next link targeting the iframe.</p>
  
  <p>I'm thinking that I will need javascript to do this.  I'm a noob though, so I'm not sure how to assess the link's URL so that I can test it against the iFrame's source and change the link's background with an "if" statement.</p>
  
  <p>I guess I can use an onClick event to change the background color (and revert the background colors of all the adjacent links) without reading the iframe src at all, but is that the most elegant way?  (There are about 10 links in all!..)</p>
  
  <p>Here's some code that I've written just to see if I can somehow read the url in the link using javascript, but it just won't work for me.  </p>
  
  <pre><code>&lt;script type="text/javascript"&gt; 
  var myLink = document.getElementById("myLink");
  var myURL = myLink.URL; 
  alert(myURL);
  &lt;/script&gt;
  </code></pre>
  
  <p>The alert just doesn't pop up.</p>
  
  <p>Any help appreciated.  Thank you.</p>