title: Can I make an onclick function not execute if the click opens a link in a new tab?
body: <p>I have a large  that show a random piece of text from a .json - file whenever it is clicked. Now sometimes the text involves links, which are set to open in a new tab. Works perfectly fine!</p>
  
  <p>However, I'd like to not have the onclick function execute, when a new tab is opened. The same as if the user opens the link by right-clicking and opening in a new tab.</p>
  
  <p>Is that possible using plain javascript? I include the selectPodcast - function to show how the link is generated.</p>
  
  <p>As I'm at it: I haven't been programming for long and I'd love to know what my code looks like to an experienced programmer. I'd imagine it's kinda cute, like when a child starts forming sentences :-)</p>
  
  <p>I tried to add a.onclick = "return false;"; to the selectPodcast - function, but that didn't work.</p>
  
  <pre><code>function getPodcast() {
      var url = "json/podcasts.json";
      var request = new XMLHttpRequest();
      request.open("GET", url);
      request.onload = function() {
          if (request.status == 200) {
              selectPodcast(request.responseText);
          }
      };
      request.send(null);
  };
  
  function selectPodcast(responseText) {
      var items = JSON.parse(responseText);
      var choice = [Math.floor(Math.random() * items.length)];
      var title = items[choice].title;
      var link = items[choice].link;
      var description = items[choice].description;
      var a = document.createElement("a");
      var br = document.createElement("br");
      var p = document.createElement("p");
      a.href = link;
      a.target = "_blank";
      a.innerHTML = title;
      p.innerHTML = description;
      var div = document.getElementById("podcast");
      div.innerHTML = "";
      div.appendChild(a);
      div.appendChild(br);
      div.appendChild(p);
  };
  </code></pre>