Chrome扩展程序窗口创建错误:无法读取未定义的属性“创建”

时间:2019-01-12 16:52:08

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

我正在尝试为Chrome扩展程序创建一个无边界窗口,但它给了我错误:

  

运行时事件处理程序中的错误。onInstalled:TypeError:无法读取未定义的属性'create'

我的background.js代码:

chrome.runtime.onInstalled.addListener(function(details) {

  chrome.app.window.create("window.html", {

      frame: "none",
      id: "Window",
      "bounds": {

          "width": 70,
          "height": 70,
          "left": 70,
          "top": 70

      },
      minWidth: 70,
      minHeight: 70,
      alwaysOnTop: true,
      resizable: false

  }, function(appwindow) {

    appwindow.contentWindow.onload = function () {



    };

  });

});

1 个答案:

答案 0 :(得分:0)

您无法在具有APIs specific to Chrome Apps的Chrome扩展程序中使用different set of APIs(除其他功能外,chrome.app.*)。

您在注释中引用的示例“ Floating for YouTube™”是一个应用程序:其清单包含一个app键。

但是,请注意Chrome Apps are deprecated on all platforms except Chrome OS。如果您现在编写了一个,则将无法在其他操作系统上发布。 “ Floating for YouTube™”是在弃用此版本之前发布的应用程序,因此它仍然可以工作,但不会永远存在。