Chrome Plugin: How to detect the URL of the selected tab


I am trying to attempt my first Google Chrome Extension and have a question. My end goal is to be able to select a button which will perform the following:

  1. Grab the current URL of the selected tab (Ex:

  2. Open a new tab using the URL from step 1 and appending a query string to the end (Ex:

Currently, I was able to figure out how to open a create a new tab which loads a specified URL. What I am unsure of how to detect the URL from the selected tab and load that value in the new tab. Suggestions? Thanks in advance!!

Code below:




body {



 function createTab() {
  chrome.tabs.create({'url': ''});

 function show_alert()
 alert("I am an alert box!");



<input type="button" onclick="createTab()" value="Create New Tab" />
<input type="button" onclick="show_alert()" value="Show alert box" />



  "name": "IGX Plugin",
  "version": "1.0",
  "description": "IGX Plugin",

  "browser_action": {
    "default_icon": "favicon.ico",
 "popup": "popup.html"
  "permissions": [


chrome.tabs.getSelected(null, function(tab) {