title: Copy Link Href within Chrome Extension
body: <p>I'm working on my first Chrome extension. Very much a beginner with javascript so bear with me...</p>
  
  <p>Basically, I've written a Chrome extension that adds a new context menu item when you right click on a hyperlink. I want to make it so when you click that context menu item, it copies the href value of the hyperlink you're clicking on (essentially, this will duplicate the 'Copy Link Address' menu item, but later I will use substrings to copy only a certain part of the URL).</p>
  
  <p>What can I do to set the sUrl variable to the href of the current hyperlink? And then what is the proper way to pass this variable to the clipboard using execCommand('copy')?</p>
  
  <p>My manifest.json is below:</p>
  
  <pre><code>{
  "name": "Copy SKU",
  "description": "Add a context menu item to copy SKU from webpages",
  "version": "1.0",
  "permissions": ["contextMenus", "clipboardWrite"],
  "background": {
  "persistent": false,
  "scripts": ["background.js"]
  },
  "manifest_version": 2
  }
  </code></pre>
  
  <p>My current background.js is below:</p>
  
  <pre><code>// Set up context menu at install time.
  chrome.runtime.onInstalled.addListener(function() {
  var context = "link";
  var title = "Copy SKU";
  var id = chrome.contextMenus.create({"title": title, "contexts":[context],
                                       "id": "context" + context});  
  });
  
  // add click event
  chrome.contextMenus.onClicked.addListener(onClickHandler);
  
  // The onClicked callback function.
  function onClickHandler(info, tab) {
  var sUrl = HYPERLINK HREF
  document.execCommand('copy', false, null);
  
  };
  </code></pre>