简体   繁体   English

如何通过单击HTML页面中的按钮来启动Chrome打包的应用

[英]How to launch Chrome packaged app by clicking on a button in a html page

I have created a Chrome packaged app and when i execute the following line in command prompt, it launches that packaged app: 我已经创建了一个Chrome打包的应用,当我在命令提示符下执行以下行时,它将启动该打包的应用:

"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --load-and-launch-app="chrome-app-path-goes-here" “ C:\\ Program Files(x86)\\ Google \\ Chrome \\ Application \\ chrome.exe” --load-and-launch-app =“ chrome-app-path-goes-here”

How can I launch this Chrome app by clicking on a button in a html page? 如何通过单击html页面中的按钮来启动此Chrome应用程序? Any javascript or jQuery way of doing this? 任何使用JavaScript或jQuery的方式吗?

Yes, it's possible. 是的,有可能。

Requirements: 要求:

  • specifically whitelisting the domain in the manifest 明确将清单中的域列入白名单
  • knowing the app's ID (you can pin it for development ) 知道应用程序的ID(您可以将其固定用于开发
  • having the app already installed. 已安装该应用程序。

Take a look at externally_connectable : docs , example . 看一看externally_connectabledocs示例

What you can do is to send a message to the app, which will wake up its Event page. 您可以做的是向应用发送一条消息,这将唤醒其“事件”页面。
From there, you can open the app's window as usual. 从那里,您可以照常打开应用程序的窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM