How can I launch a Chrome Packaged App through javascript?

允我心安 提交于 2019-12-29 07:17:09

问题


I want to be able to launch my packaged chrome app via javascript either on-page or through an extension. Am I able to do this? I have done a fair amount of research with no answer in either direction. Can somebody at least point me in the right direction?


回答1:


chrome.management.launchApp can be used to launch an app in an extension.

The API reference is available here: https://developer.chrome.com/extensions/management.html#method-launchApp.




回答2:


You can make certain resources in your extension available, and then you should be able to "window.location" to that.

The URL scheme is chrome-extension://[PACKAGE ID]/[PATH].

Example:

//This is **not** in your packaged app, but in another web page
window.location = "chrome-extension://abdecbedphjijkaed/index.html";

In your packaged app, you'll need to declare which resources can be reached via a url in your manifest:

"web_accessible_resources": [
    "images/my-awesome-image1.png",
    "images/my-amazing-icon1.png",
    "index.html"
]

See more: https://developer.chrome.com/extensions/manifest.html#web_accessible_resources

NOTE: This might not work. While the user can use "chrome://" urls, I'm not sure if web pages can




回答3:


This feature is coming. See Issue 111422: Add ability for apps to register for URL handling.



来源:https://stackoverflow.com/questions/17097941/how-can-i-launch-a-chrome-packaged-app-through-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!