Reputation: 59
I'm building an extension for chrome, and I'm trying to pass the chrome tab url (with JS) dynamically to the html file. I read other people questions regarding the same issue, but it didn't work in my case.
My knowledge of JS and HTML is basic, but I don't know how to move the parameter data between them.
Thanks!
Upvotes: 2
Views: 255
Reputation: 6926
First, set the permissions for the tab API :
"permissions": [
"tabs"
]
And then store the URL :
chrome.tabs.getSelected(null,function(tab) {
var tablink = tab.url;
});
Or another way: (preferred)
chrome.tabs.query({'active': true}, function (tabs) {
var url = tabs[0].url;
});
Upvotes: 1