I’m trying to create a simple plugin for Google Chrome. One of the functions would be a return to the last used tab, but I don’t know how to do it.
So, is there any way to get the last used tab?
Advertisement
Answer
You could try adding a hook into the onSelected event of the tabs and just saving that variable… soemthing like this:
JavaScript
x
8
1
var curTabID = 0;
2
var curWinID = 0;
3
4
chrome.tabs.onSelectionChanged.addListener(function(tabId, selectInfo) {
5
curTabID = tabId;
6
curWinID = selectInfo.windowId;
7
});
8
Then you have the window id and the tab id at all times.