title: Opening external links from select/option dropdown in a new tab
body: <p>I have a select-option dropdown with links, both internal and external. I want the external links (and only them) to open in a new tab. This is what I have. </p>
  
  <pre><code>&lt;select id="my-dropdown"&gt;
      &lt;option value=""&gt;A list of internal and external links&lt;/option&gt;
      &lt;option value="http://www.someurl.com"&gt;External Link&lt;/option&gt;
      &lt;option value="/internal/page"&gt;Internal links&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>JS to open the links.</p>
  
  <pre><code>&lt;script&gt;
      document.getElementById("my-dropdown").onchange = function() {
          if (this.selectedIndex!==0) {
              window.location.href = this.value;
          }        
      };
  &lt;/script&gt;
  </code></pre>
  
  <p>EDIT: Changing the JS to this does it:</p>
  
  <pre><code>&lt;script&gt;
      document.getElementById("my-dropdown").onchange = function() {
  
          var externalLinkCheck = this.options[this.selectedIndex].value;
  
          if (this.selectedIndex!==0 &amp;&amp; externalLinkCheck.substring(0,4) == "http") {
              window.open(this.value, '_blank');
          } else {
              window.location.href = this.value;
          }        
      };
  &lt;/script&gt;
  </code></pre>
  
  <p><a href="https://stackoverflow.com/users/673269/chriserwin">chriserwin</a>'s answer below is also good! Thanks!</p>