Google chrome extension 如何在新选项卡中打开我的Chrome扩展?
嗨,我在stackoverflow上发现了其他类似的问题,但没有一个解决了这个问题 我希望我的chrome分机/应用程序在一个完整的选项卡中打开,就像邮递员分机是如何打开的一样 我的manifest.jsonGoogle chrome extension 如何在新选项卡中打开我的Chrome扩展?,google-chrome-extension,tabs,Google Chrome Extension,Tabs,嗨,我在stackoverflow上发现了其他类似的问题,但没有一个解决了这个问题 我希望我的chrome分机/应用程序在一个完整的选项卡中打开,就像邮递员分机是如何打开的一样 我的manifest.json { "name": "Sample App", "manifest_version": 2, "version": "0.0.1", "app": { "background": { "scripts": ["main.js"] } }, "icons": { "128":
{
"name": "Sample App",
"manifest_version": 2,
"version": "0.0.1",
"app": {
"background": {
"scripts": ["main.js"]
}
},
"icons": { "128": "icon.png" },
"permissions" : ["tabs" ]
}
My main.js(background.js的别名)
index.html是打开新选项卡时要加载的文件。
chrome.app.runtime.onLaunched
仅适用于chrome应用程序,不适用于扩展名。当Chrome浏览器启动时,背景页的代码将自动运行,因此您可以直接从Chrome.tabs.create(…)
开始
此外,您还需要包括
index.html
和扩展中包含的任何资源,该页面将在您的清单的某个部分中使用这些资源。我第一次在stackoverflow上回复时,请小心
我发现在manifest.json文件中添加“launch”:{“local_path”:“index.html”}要容易得多。请参阅下面的示例清单文件
{
"manifest_version" : 2,
"name": "Hello World!",
"description": "My first Chrome App.",
"version": "0.1",
"app": {
"launch" : {
"local_path" : "index.html"
}
},
"icons": { "16": "icon.png" }
}
请记住,这个示例非常基本,它已经删除了一些不必要的信息,例如背景脚本,但它应该可以完成您想要的
{
"manifest_version" : 2,
"name": "Hello World!",
"description": "My first Chrome App.",
"version": "0.1",
"app": {
"launch" : {
"local_path" : "index.html"
}
},
"icons": { "16": "icon.png" }
}