How to declare Chrome extension to handle specific URL scheme?

主宰稳场 提交于 2019-12-22 05:40:28

问题


I'd like to write an extension that handles specific URLs that have custom scheme (myscheme://). How do I declare my extension so it is invoked on such a request and intercepts it? (The URL can be clicked, typed directly in the address bar, passed in the command line, etc.). This is probably a beginner question, but I'm a beginner!


回答1:


There is a JavaScript API that you can use for this.

navigator.registerProtocolHandler("mailto",
                                  "https://www.example.com/?uri=%s",
                                  "Example Mail");


来源:https://stackoverflow.com/questions/8428963/how-to-declare-chrome-extension-to-handle-specific-url-scheme

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