When I paste an URL generated by Teams into a browser (particularly Chrome), the browser asks me whether to open the link in the browser or in the Teams external application. What is the mechanism behind that makes this possible? Does Teams register some sort of browser extension when installed on my PC? How can I invoke a random application from a browser and pass an URL to it?
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
The local application registers a custom URI scheme with the operating system. So instead of a URI with an
https://
for Web browsing, the app might declare (upon installation) that it can open ax-custom-protocol://
scheme.The specifics of how a local app does this vary by platform (Windows, macOS, Android, iOS, etc.) but when the browser encounters ‘x-custom-protocol://’ that it suspects it can’t handle, it offers to open in the external application.
In the Teams case on Windows, when you install Teams it registers
msteams://
as its URI scheme ("protocol handler" to some) and then when the browser encounters anmsteams://
link, it asks if you want to hand it off to the installed Teams app.Apps like Teams and Zoom, register custom URL schemes or protocols on your operating system when they are installed. These schemes are used to uniquely identify the application and provide a way for other programs, like web browsers, to communicate with them. For example, Teams might register a URL scheme like msteams:// . Modern browsers are designed to recognize these custom protocols/schemes. When you paste a link with a recognized custom protocol / scheme into the browser’s address bar, the browser identifies the protocol and understands that it corresponds to an external application.
To invoke a random application from a browser and pass a URL to it, you would need to follow a similar approach. The application would need to register a custom URL protocol on your system, and the browser would need to be capable of recognizing and handling it.