Nes*_*Web 3 javascript google-chrome google-chrome-extension
我如何知道是否从另一个选项卡页面上的链接或内容脚本打开了一个选项卡?
如果可以的话,我也需要该标签的信息。
chrome.tabs.onCreated.addListener(function(id, info, tab){
// tab doesn't contain any such info
});
Run Code Online (Sandbox Code Playgroud)
您的回调格式错误。
chrome.tabs.onCreated.addListener(function(tab){
// You now have things like tab.id exposed
// If you have "tabs" permission, also things like tab.url
// You also have tab.openerTabId for "referrer" tab
// If you have host permissions for the tab:
chrome.tabs.executeScript(
tab.id,
{ code: "document.referrer;" },
function(result) {
// Here, you have the "real" referrer,
// which would be empty for tabs opened via `chrome.tabs`
}
);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1101 次 |
| 最近记录: |