且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Chrome扩展程序:2个打开的窗口中的活动选项卡是什么?

更新时间:2023-12-05 19:21:16

进行查询以选择最后一个焦点窗口:

Make your query to select the last focused Window:

chrome.tabs.query({ active: true, lastFocusedWindow: true }, function (tabs) {
  //...
});

注意:***不要服用currentWindow: true,因为:

Note: Better don't take currentWindow: true because:

当前窗口是包含当前正在执行的代码的窗口.重要的是要意识到这可能与最上面的窗口或聚焦的窗口不同.

The current window is the window that contains the code that is currently executing. It's important to realize that this can be different from the topmost or focused window.

来源: http://developer.chrome .com/extensions/windows.html#current-window