【问题标题】:Open a Chrome app within a tab在标签页中打开 Chrome 应用
【发布时间】:2012-10-29 03:53:40
【问题描述】:

此问题始于 Google Chrome 23 版。当启动事件触发时,我的 Chrome 应用程序会打开一个选项卡以显示其 UI。

chrome.app.runtime.onLaunched.addListener(function() 
{
   chrome.tabs.create(
   {
      url: "../../index.html"
   });
});

此方案在 Google Chrome 版本 23 之前有效。现在在运行我的应用程序时收到以下异常。

Error in event handler for 'app.runtime.onLaunched': Cannot call method 'create' of undefined TypeError: Cannot call method 'create' of undefined

在开发人员工具中检查chrome 对象后,我注意到chrome.tabs 未定义。

我知道我不必在 manifest.json 中明确设置“tabs”权限,因为根据http://developer.chrome.com/extensions/tabs.html,创建、更新和删除方法不需要“tabs”权限。

在尝试将“tabs”权限显式添加到 manifest.json 文件后,我在 chrome://chrome/extensions/ 上收到此应用程序的消息。

There were warnings when trying to install this extension: 'tabs' is only allowed for extensions and legacy packaged apps, and this is a packaged app.

如果我按照https://developers.google.com/chrome/web-store/docs/choosing 给出的图表并选择了打包的应用程序,因为我的应用程序的 UI 不小,我不打算扩展 Chrome 的 UI 并且我无法使用 chrome.tabs,那么我该如何打开我的应用程序的 UI 在一个新的或现有的选项卡中,而不必创建一个弹出窗口(这很烦人而且对用户不友好)?

【问题讨论】:

标签: javascript google-chrome google-chrome-extension google-chrome-devtools


【解决方案1】:

你试过 chrome.app.runtime.onLaunched 中的 window.open()

【讨论】:

猜你喜欢
  • 2014-05-05
  • 2019-09-04
  • 2012-03-23
  • 1970-01-01
  • 2017-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多