如何声明Chrome扩展来处理特定的URL方案? [英] How to declare Chrome extension to handle specific URL scheme?

查看:277
本文介绍了如何声明Chrome扩展来处理特定的URL方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个扩展来处理具有自定义方案的特定URL(myscheme://)。我如何声明我的扩展,以便在这样的请求上调用它并截获它? (URL可以被点击,直接在地址栏中输入,在命令行中传递等)。这可能是一个初学者的问题,但我是一个初学者!

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!

推荐答案

JavaScript API ,您可以使用它。

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

这篇关于如何声明Chrome扩展来处理特定的URL方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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