Skip to content

Instantly share code, notes, and snippets.

@jxpx777
Created February 19, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jxpx777/2eb0f5fbdfbd8800a356 to your computer and use it in GitHub Desktop.
Save jxpx777/2eb0f5fbdfbd8800a356 to your computer and use it in GitHub Desktop.
The goal is to open a URL in the active tab. If one does not exist, we should open a new tab for it.
function openURLInActiveTab(url){
if (tabs.activeTab.url === undefined) {
tabs.open({url: url, onOpen: function onOpen(tab) { console.log("[GLOBAL]: Opened tab: " + tab); tab.activate(); tab.url = url; }});
}
else {
tabs.activeTab.url = url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment