title: Copy current URL to clipboard
body: <p>Not sure why this has been so difficult for me today, but for some reason I cannot seem to get it to copy the current URL to the clipboard. Overall, I'm looking for a way to do it <em>without</em> needing to create some hidden text elements.</p>
  
  <p>This is what I'm trying so far:</p>
  
  <pre><code>var shareBtn = document.querySelector(".share-button");
  
  shareBtn.addEventListener('click', function(event) {
    var cpLink = window.location.href;
    cpLink.select();
  
    try {
      var successful = document.execCommand('copy');
      var msg = successful ? 'successful' : 'unsuccessful';
      console.log('Copy command was ' + msg);
    } catch (err) {
      console.log('Oops, unable to copy');
    }
    event.preventDefault;
  });
  </code></pre>
  
  <p>When I try to go about it using the <code>.select()</code> I get this error:
  <code>t.select is not a function</code>
  So I'm not 100% sure what the best way to go about this. Again, without using jQuery (or any other JS library) and not using some sort of hidden textfield.</p>