Chrome扩展程序:获取上次使用的标签 [英] Chrome extension: Get last used tab
本文介绍了Chrome扩展程序:获取上次使用的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为Google Chrome创建一个简单的插件.功能之一是返回到上次使用的选项卡,但我不知道该怎么做.
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?
推荐答案
您可以尝试将钩子添加到选项卡的onSelected事件中,然后保存该变量...类似这样的东西:
You could try adding a hook into the onSelected event of the tabs and just saving that variable... soemthing like this:
var curTabID = 0;
var curWinID = 0;
chrome.tabs.onSelectionChanged.addListener(function(tabId, selectInfo) {
curTabID = tabId;
curWinID = selectInfo.windowId;
});
然后,您将始终拥有窗口ID和标签ID.
Then you have the window id and the tab id at all times.
这篇关于Chrome扩展程序:获取上次使用的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文