Leon Cunningham
Leon Cunningham

Reputation: 31

chrome.tab.onactivated

Can someone please show me how to use the chrome.tabs.onActivated.

I would like to refresh the tab that is clicked/activated if the url equals: www.example.com.

Or if this is the wrong method please tell me what to use.

Upvotes: 2

Views: 2527

Answers (1)

Konrad Dzwinel
Konrad Dzwinel

Reputation: 37903

Firstly, be sure to put "tabs" permission in your manifest.json file. Then, use chrome.tabs.onActivated in your background page script. Each time this event will be called you will get activeInfo object containing currently active tab ID. Having this ID you can fetch the tab and see what URL is it set to. When you are certain that this is a tab you are looking for (URL matches) you can reload it.

Upvotes: 2

Related Questions