Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Google Chrome to open a custom URL scheme handler?

I have a html test page with the link:

<a href="customprotocol:information-from-browser">Link.</a>

If I open this in Safari and click on the link, the handling app (a custom app) opens correctly.

But when I open this page in Google Chrome and click on the link, the app does not open.

The clicked link fires a GET request, but it's status is cancelled. And the whole request is shown in red in the Network Inspector.

chrome network tab

I thought maybe Chrome does this for security reasons, and blocks unregistered custom URL schemes by default. To get around this, I added a bit of javascript to the html page (from this question):

window.location.assign("customprotocol:");

which pops up a dialog asking if the user wants to associate customprotocol: with the app.

Even after pressing OK and thus setting the customprotocol: handler recognized by chrome, the link still does not launch the app. It remains a cancelled request.

Why is this? How do I get this to work in Google Chrome?


Note 1: AFAIK, all my software are updated to the latest versions.

Note 2: The cancelled request has no response and preview information. Under timing, the request shows as stalled.

like image 361
Capstone Avatar asked Apr 10 '17 16:04

Capstone


People also ask

How do I enable full URL in Chrome?

Just right-click in Chrome's address bar select “Always show full URLs” to make Chrome show full URLs. Chrome will now always show the full URL of every web address you open. To disable this feature, right-click in the address bar again and uncheck it.

Where is the protocol handler in Chrome?

The Protocol Handler Icon Your first step is to start Chrome on your computer, open Gmail, then look up at your top address bar. Look for the Protocol Handler icon at the top right. This looks like a gray-colored diamond that's to the left of a star, with the latter being used for bookmarking.

How do I show protocol in Chrome?

To use it, you first need to enable it: open the DevTools by right-click any page and choosing “Inspect Element". Go to the network tab, right-click the columns in the and enable the “Protocol” column. Once enabled, refresh the page and it'll show you what protocols each resource are using.


1 Answers

In general, it seems that protocols are actually passed onto the OS if chrome doesn't recognize them. So you may have just confused your chrome.

Look how steam://browsemedia works for Valve's game manager Steam. Debug that link and I bet it actually gets the same results that you got. Try, mailto:me it successfully opens my email client. Obviously the browser doesn't need to send and actual request, So I would ignore all your request analyzing. I tested this, the "Stalled" status is CORRECT.

I think you need to reset whatever customhandler settings you have got in chrome. I think it may be interfering with letting the OS deal with it.

like image 82
Worthy7 Avatar answered Oct 12 '22 08:10

Worthy7