[英]All chrome.tabs present the same error
我正在尝试制作一个每2分钟重新加载一个标签的扩展程序,但我希望它尝试重新加载即使互联网处于脱机状态(因此它会在重新启动时重新加载)。 当窗口发出错误(例如离线)时,使用location.reload()不起作用,所以我认为最好的方法是使用chrome.tabs.reload()。
问题是,所有chrome.tabs给我一个类似的错误,如果我尝试使用一个空参数它应该工作,因为它根据文档默认为当前选项卡,而是:
chrome.tabs.reload({});
Uncaught TypeError: Cannot call method 'reload' of undefined
如果我尝试获取当前标签ID:
chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
console.log(tabs[0]);
});
Uncaught TypeError: Cannot call method 'query' of undefined
同样,每个chrome.tabs
都有类似的错误,“不能调用未定义的xxyyzz”。 这就好像铬无法看到我的标签,发生了什么?
我的manifest.js是:
{
"manifest_version": 2,
"name": "test",
"description": "",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"js": ["reload.js"],
"run_at": "document_end"
}
],
"permissions": [
"tabs","storage","http://www.google.com"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.