发生点击事件时,在扩展名图标上的chrome上固定位置打开扩展名页面

时间:2019-07-12 10:58:00

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

我需要创建扩展。 单击或悬停时,我需要在顶部创建一个扩展屏幕固定位置为chrome。 但我不知道任何一种api。

chrome.tabs.create({ url: chrome.extension.getURL('landing.html'), active: true }, function(tab) { chrome.windows.create({ tabId: tab.id, type: 'popup', 'width': w, 'height': h, 'left': left, 'top': top, focused: true }); });

,类型为type: 'popup'type: 'normal'type: 'devtools' 但是无论如何我都无法实现我所需要的。 我做错了什么? 或Chrome中没有针对该API的API。 我需要Chrome的这种行为。

enter image description here

1 个答案:

答案 0 :(得分:0)

browserAction的弹出窗口位于页面顶部,在导航栏中的操作按钮下方(如您的屏幕快照中所示)。 可以使用此弹出窗口提供的HTML的样式表来设置尺寸(而不是位置)。

manifest.json:

  "browser_action": {
    "default_title": "The tooltip of the action button",
    "default_icon": {
      "16": "icon16.png",
      "32": "icon32.png"
    },
    "default_popup": "your_popup.html",
    "browser_style": true
  }