I'm trying to open a new tab in Google Chrome Extension. I've simplified my test case to this HTML:
<a id="link" href="http://www.example.com">example</a>
Here's code that I've:
$('#link').click(function () {
chrome.browserAction.onClicked.addListener(function (activeTab) {
var newURL = "http://www.youtube.com/watch?v=oHg5SJYRHA0";
chrome.tabs.create({ url: newURL });
});
});
I found the answer chrome.browserAction.onClicked.addListener
in this thread:
Google Chrome Extensions - Open New Tab when clicking a toolbar icon
But this doesn't work when I click my link and I don't understand how to use chrome.browserAction.onClicked.addListener
in my case.
Any help appreciated.