122333123183
122333123183

Reputation: 59

Get url from google chrome tab

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

Answers (1)

Riju Mahna
Riju Mahna

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

Related Questions