【发布时间】:2025-11-24 13:45:02
【问题描述】:
我有创建扩展的需求。 我需要创建一个扩展屏幕,在单击或悬停时将位置固定为顶部的铬合金。 但我不知道任何那种 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。
我需要 chrome 的这种行为。
【问题讨论】:
-
没有 API 可以移动 browserAction/pageAction 弹出窗口。您可以使用 chrome.windows.create 创建一个新的小窗口。或者,您可以在当前页面中插入一个看起来像模态的 DOM 元素。或者您可以编写一个nativeMessaging 主机实用程序,该实用程序使用低级操作系统方法来移动标准扩展弹出窗口。
标签: javascript google-chrome google-chrome-extension google-chrome-devtools google-chrome-app