chrome扩展如何在包应用程序上运行内容脚本

时间:2012-03-12 15:27:21

标签: google-chrome-extension content-script

我正在制作Chrome套餐应用。这是我的manifest.json

  "app": {
"launch": {
  "local_path": "main.html"
}

"content_scripts": [
{
  "matches": ["http://*/*", "https://*/*", "file://*/*"],
  "js": ["jquery-1.7.min.js", "content_script.js"],
  "all_frame": "true"
}

为什么我的内容脚本无法在main.html上运行?内容脚本可以在包应用程序上运行吗?

1 个答案:

答案 0 :(得分:1)

内容脚本无法在chrome-extension:协议 [1] 上运行。因此,内容脚本不会在您的应用中运行。

main.html中包含脚本:

<script src="jquery-1.7.min.js"></script>
<script src="content_script.js"></script>

[1]:唯一允许的协议是http:https:file:。对于所有其他协议,即使指定了<all_urls>,也不会注入内容脚本。