0

我正在开发 google chrome 的扩展程序,它在页面加载 2 秒后重新加载选项卡一次,然后等待 30 分钟并关闭选项卡或 google chrome 窗口。我在我的 1.js 文件中尝试了这些脚本,但它们似乎都不起作用

    document.documentElement.style.display = 'none';
    setTimeout(function() {document.documentElement.style.display = '';}, 1000);
    chrome.tabs.reload()
    document.documentElement.style.display = 'none';
    setTimeout(function() {document.documentElement.style.display = '';}, 1000);
    chrome.tabs.remove()

这是我的清单文件:

    {"name": "My First Extension",
    "version": "1.0",
    "manifest_version": 2,
    "description": "The first extension that I made.",
    "content_scripts": 
    [{"matches": ["http://*/*"],
    "js": ["1.js"],
    "run_at": "document_start",
    "permissions": 
    ["tabs", "http://*/*"]}]}

她在 java 控制台中是这样说的:

    Uncaught TypeError: Cannot call method 'reload' of undefined 

谢谢你们

4

1 回答 1

0

您确定您正在正确调用 chrome.tabs.* 方法吗?请提供一个片段。

于 2012-07-10T08:40:16.143 回答