如何使用 JavaScript 打开扩展程序的弹出窗口? [英] How can I open my extension's pop-up with JavaScript?

查看:29
本文介绍了如何使用 JavaScript 打开扩展程序的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 JavaScript 函数,它会像单击扩展程序图标一样打开我的扩展程序.我知道如何在新标签页中打开我的扩展程序:

I am trying to write a JavaScript function that will open my extension like when the extension icon is clicked. I know how to open my extension in a new tab:

var url = "chrome-extension://kelodmiboakdjlbcdfoceeiafckgojel/login.html";
window.open(url);

但是我想在浏览器的右上角打开一个弹出窗口,就像点击扩展程序图标一样.

But I want to open a pop-up in the upper right corner of the browser, like when the extension icon is clicked.

推荐答案

Chromium 开发团队明确表示他们不会启用此功能.请参阅功能请求:以编程方式打开扩展弹出气泡:

The Chromium dev team has explicitly said they will not enable this functionality. See Feature request: open extension popup bubble programmatically :

浏览器和页面操作弹出窗口的理念是它们必须由用户操作触发.我们的建议是使用新的 html 通知功能...

The philosophy for browser and page action popups is that they must be triggered by user action. Our suggestion is to use the new html notifications feature...

桌面通知可用于向用户展示一个小的 HTML页面很像您的弹出窗口.这不是一个完美的替代品,但它可能会提供您需要的功能类型.

Desktop notifications can be used progammatically to present the user with a small HTML page much like your popup. It's not a perfect substitution, but it might provide the type of functionality you need.

这篇关于如何使用 JavaScript 打开扩展程序的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆