Navigator.msLaunchUri() - Web APIs 编辑

Non-standard

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The msLaunchUri() method is a Microsoft extension to the Navigator interface, which starts a service or app, such as an email client, that handles a given protocol. The Uniform Resource Identifier (URI) contains the protocol for the default service or app, such as mailto://test@contoso.com.

This proprietary method is specific to Internet Explorer, and Microsoft Edge versions 18 and lower.

Syntax

navigator.msLaunchUri(uri, successCallback, noHandlerCallback);

Parameters

uri
A DOMString specifying the URL containing including the protocol of the document or resource to be displayed.
successCallbackOptional
A function matching the signature of MSLaunchUriCallback to be executed if the protocol handler is present.
noHandlerCallbackOptional
A function matching MSLaunchUriCallback to be executed if the protocol handler is not present.

Return value

undefined.

Usage notes

If a default protocol handler is available on the system that matches the URI, the successCallback is invoked, otherwise, the noHandlerCallback is called.

To help protect a user's privacy, Windows displays a prompt for the user to allow the service or app to be launched. The user can choose to not see the prompt after the first instance for a particular protocol and automatically open the app or service without a user intervention. The msLaunchUri() method does not support HTTP, Secure Hypertext Transfer Protocol (HTTPS), File Transfer Protocol (FTP), file, res, JavaScript, or Microsoft Visual Basic Scripting Edition (VBScript) protocols.

If the user's system does not have a program registered to handle a specific protocol, and a noHandlerCallback is provided, Windows Internet Explorer will invoke the noHandlerCallback. This enables developers to provide a custom fallback experience for the user. If a handler doesn't exist, and the developer doesn't provide a noHandlerCallback, then Internet Explorer displays a dialog that asks the user if they want to allow the action. If the user allows it, the user is then prompted to look in the Windows Store for an app to handle the protocol. If multiple programs are registered on the system for the given protocol and no default has been chosen, Windows prompts the user to choose one.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:125 次

字数:4166

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文