[英]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.