title: How do I open up a random url from a list of url's in a new time each time it is clicked?
body: <p>I have some code that'll allow me to open up a random website from a list of websites but I'd like to open each one up in a new tab, how do I do this?</p>
  
  <h3>Information you may need</h3>
  
  <p>the code</p>
  
  <pre><code>    &lt;html&gt;
      &lt;button onclick="randomLink();OpenInNewTab();"&gt;Click here to go somewhere else!    &lt;/button&gt;
  
      &lt;script type="text/javascript"&gt;
  
  
      var randomLink = function () {
  
          // first create an array of links
          var links = [
              "bbc.com",
              "google.com",
              "youtube.com",
          "facebook.com"
          ];
  
          // then work out the maximum random number size
          // by counting the number of links in the array
          var max = (links.length)
  
          // now generate a random number
          var randomNumber = Math.floor(Math.random()*max);
  
          // use that random number to retrieve a link from the array
          var link = links[randomNumber];
  
          // change the location of the window object
          window.location = "http://" + link;
  
          // Opens a new tab.
          function OpenInNewTab(url) {
          var win = window.open(url, '_blank');
           win.focus();
  }
      }
      &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I tried doing the action in question at two different points and hope you're input can help to correct this.</p>
  
  <p>Location 1</p>
  
  <pre><code>&lt;button onclick="randomLink();OpenInNewTab();"&gt;Click here to go somewhere else!
  </code></pre>
  
  <p>Location 2</p>
  
  <pre><code>// Opens a new tab.
  function OpenInNewTab(url) {
  var win = window.open(url, '_blank');
  win.focus();
  </code></pre>
  
  <p>The following web address is what the code currently looks like and does.</p>
  
  <ul>
  <li><a href="http://holyshitthisisalotofuselesscraponotherwebsites.com/" rel="nofollow">http://holyshitthisisalotofuselesscraponotherwebsites.com/</a></li>
  </ul>
  
  <p>*EDIT : The only changes I made are the websites.They're much more on the live demo.</p>