Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome extension 控制台的简单chrome扩展日志记录不起作用_Google Chrome Extension - Fatal编程技术网

Google chrome extension 控制台的简单chrome扩展日志记录不起作用

Google chrome extension 控制台的简单chrome扩展日志记录不起作用,google-chrome-extension,Google Chrome Extension,尝试编写我的第一个非常简单的chrome扩展:它应该编写一些消息来控制台。这是我的密码: manifest.json { "manifest_version": 2, "name" : "Hello world", "version" : "1.0", "description" : "This is a simple chrome extention", "background": "background.html" } background.html

尝试编写我的第一个非常简单的chrome扩展:它应该编写一些消息来控制台。这是我的密码:

manifest.json

{
    "manifest_version": 2,
    "name" : "Hello world",
    "version" : "1.0",
    "description" : "This is a simple chrome extention",
    "background": "background.html"
}
background.html

<script type="text/javascript">

    window.onload = function() {
        window.setInterval( function() {
            console.log("Hello world");
        }, 10000);
    }
</script>

window.onload=函数(){
setInterval(函数(){
log(“你好世界”);
}, 10000);
}

但它没有在chrome控制台中记录任何内容。这里出了什么问题?

在现代Chrome中,最好使用(非持久性背景页)并只声明脚本

  • manifest.json:

    “背景”:{
    “脚本”:[“background.js”],
    “持续”:假
    },
    
  • background.js:

    window.setInterval(函数(){
    log(“你好世界”);
    }, 10000);
    
    它在中打印,而不是在网页控制台中


声明html页面有意义的唯一情况是您实际使用背景页面的DOM,例如画布。

在现代Chrome中,最好使用(非持久性背景页面)并仅声明脚本

  • manifest.json:

    “背景”:{
    “脚本”:[“background.js”],
    “持续”:假
    },
    
  • background.js:

    window.setInterval(函数(){
    log(“你好世界”);
    }, 10000);
    
    它在中打印,而不是在网页控制台中


声明html页面有意义的唯一情况是实际使用背景页面的DOM,例如画布。

Ok。已更改为“后台页面”,并在chrome扩展中收到以下警告:““后台页面”需要清单版本1或更低。”。不管怎么说,我的打字不是“随机”的,但恐怕我看到的例子已经被弃用了。已更改为“后台页面”,并在chrome扩展中收到以下警告:““后台页面”需要清单版本1或更低。”。无论如何,我的输入不是“随机”的,但我恐怕我看到的例子已经被弃用了。用这个链接来理解它:无论如何,谢谢。用这个链接来理解它:无论如何,谢谢。