<legend id='Asavy'><style id='Asavy'><dir id='Asavy'><q id='Asavy'></q></dir></style></legend>

  • <tfoot id='Asavy'></tfoot>

    <i id='Asavy'><tr id='Asavy'><dt id='Asavy'><q id='Asavy'><span id='Asavy'><b id='Asavy'><form id='Asavy'><ins id='Asavy'></ins><ul id='Asavy'></ul><sub id='Asavy'></sub></form><legend id='Asavy'></legend><bdo id='Asavy'><pre id='Asavy'><center id='Asavy'></center></pre></bdo></b><th id='Asavy'></th></span></q></dt></tr></i><div id='Asavy'><tfoot id='Asavy'></tfoot><dl id='Asavy'><fieldset id='Asavy'></fieldset></dl></div>

    <small id='Asavy'></small><noframes id='Asavy'>

      • <bdo id='Asavy'></bdo><ul id='Asavy'></ul>

      1. 从网页安装 URI 方案的服务处理程序

        Install a service handler for URI scheme from webpage(从网页安装 URI 方案的服务处理程序)

            <tbody id='le59q'></tbody>
          <tfoot id='le59q'></tfoot>
            <bdo id='le59q'></bdo><ul id='le59q'></ul>

            <small id='le59q'></small><noframes id='le59q'>

          • <legend id='le59q'><style id='le59q'><dir id='le59q'><q id='le59q'></q></dir></style></legend>
                <i id='le59q'><tr id='le59q'><dt id='le59q'><q id='le59q'><span id='le59q'><b id='le59q'><form id='le59q'><ins id='le59q'></ins><ul id='le59q'></ul><sub id='le59q'></sub></form><legend id='le59q'></legend><bdo id='le59q'><pre id='le59q'><center id='le59q'></center></pre></bdo></b><th id='le59q'></th></span></q></dt></tr></i><div id='le59q'><tfoot id='le59q'></tfoot><dl id='le59q'><fieldset id='le59q'></fieldset></dl></div>

                  本文介绍了从网页安装 URI 方案的服务处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  从 Chrome 访问 Google Mail 或 Google Calendar 时,地址栏中会出现一个小图标,允许为 URI 方案安装自定义服务处理程序(图中用红色方块标记).

                  When accessing Google Mail or Google Calendar from Chrome, small icon appears in addressbar allowing to install custom service handler for URI scheme (marked with red square in picture).

                  图标的工具提示是:此页面要安装服务处理程序.当我点击图标并允许 Google Mail 处理 mailto: 链接时,所有 mailto: 链接都会在 Chrome 中打开.

                  Tooltip for icon is: This page wants to install a service handler. When I click icon and allow Google Mail to handle mailto: links, all mailto: links are opening in Chrome.

                  是否可以像 Google Mail 一样创建能够为我的自定义 URI 方案安装自定义处理程序的网页?

                  Is it possible to create webpage that will be able to install custom handler for my custom URI scheme just like Google Mail do?

                  推荐答案

                  对于 Chrome (13+)、Firefox (3.0+) 和 Opera (11.60+),可以使用以下方法将 Web 应用程序注册为自定义 URI 方案的服务处理程序JavaScript API:

                  For Chrome (13+), Firefox (3.0+) and Opera (11.60+) it is possible to register web application as service handler for custom URI scheme using JavaScript API:

                  window.navigator.registerProtocolHandler(protocol, uri, title);
                  

                  • protocol 是网站希望处理的协议,指定为字符串.
                  • uri 是作为字符串的处理程序的 URI.您可以包含%s"以指示在何处插入要处理的文档的转义 URI.
                  • title 是以字符串形式呈现给用户的处理程序的标题.
                    • protocol is the protocol the site wishes to handle, specified as a string.
                    • uri is the URI to the handler as a string. You can include "%s" to indicate where to insert the escaped URI of the document to be handled.
                    • title is the title of the handler presented to the user as a string.
                    • 特别是对于 Chrome 有一个限制,不允许使用不以 web+ 前缀开头的自定义方案(标准方案除外:mailtommsnntprtspwebcal).因此,如果您想像 GMail 一样将您的 Web 应用程序注册为服务处理程序,您应该编写如下内容:

                      Specifically for Chrome there is a limitation that does not allow to use custom schemes that don't start with web+ prefix (except standard ones: mailto, mms, nntp, rtsp and webcal). So if you want to register your web app as service handler as GMail do, you should write something like this:

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

                      navigator.registerProtocolHandler("web+myscheme", "https://www.example.com/?uri=%s", "My Cool App");
                      

                      注意 URI 模式,它必须包含 %s ,它将替换为用户点击的链接的实际 URI.例如:

                      Pay attention at URI pattern, it have to contain %s which will be replaced with actual URI of the link user clicks. For example:

                      <a href="web+myscheme:some+data">Open in "My Cool App"</a>
                      

                      将触发 GET 请求到 http://www.example.com/?uri=web%2Bmyscheme%3Asome%20data

                      这里有一些有用的链接:

                      Here are some useful links:

                      • 标准 http://www.whatwg.org/specs/web-apps/current-work/#custom-handlers
                      • MDN https://developer.mozilla.org/en-US/docs/DOM/navigator.registerProtocolHandler
                      • HTML5ROCKS http://updates.html5rocks.com/2011/06/Registering-自定义协议处理程序

                      这篇关于从网页安装 URI 方案的服务处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                      本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Gradient Button to background-color blinks on hover(悬停时背景颜色的渐变按钮闪烁)
                  How to make hovering over active button not use hover effect?(如何使悬停在活动按钮上不使用悬停效果?)
                  html javascript show image hover(html javascript 显示图像悬停)
                  How to get css hover values on click?(如何在点击时获得 css 悬停值?)
                  Change background image on link hover(更改链接悬停时的背景图像)
                  Highlight multiple items on hover#39;s condition(突出显示悬停条件下的多个项目)
                • <small id='7sXfr'></small><noframes id='7sXfr'>

                        <tfoot id='7sXfr'></tfoot>
                          <tbody id='7sXfr'></tbody>
                        • <i id='7sXfr'><tr id='7sXfr'><dt id='7sXfr'><q id='7sXfr'><span id='7sXfr'><b id='7sXfr'><form id='7sXfr'><ins id='7sXfr'></ins><ul id='7sXfr'></ul><sub id='7sXfr'></sub></form><legend id='7sXfr'></legend><bdo id='7sXfr'><pre id='7sXfr'><center id='7sXfr'></center></pre></bdo></b><th id='7sXfr'></th></span></q></dt></tr></i><div id='7sXfr'><tfoot id='7sXfr'></tfoot><dl id='7sXfr'><fieldset id='7sXfr'></fieldset></dl></div>
                          <legend id='7sXfr'><style id='7sXfr'><dir id='7sXfr'><q id='7sXfr'></q></dir></style></legend>
                            <bdo id='7sXfr'></bdo><ul id='7sXfr'></ul>