How and where do I use navigator.registerProtocolHandler to make it work?
.
In this section, you can call the following function to add a custom protocol handler:
navigator.registerProtocolHandler('web+custom', 'http://example.com/rph?q=%s', 'My App');
When I call it from the console, I get
Uncaught DOMException: Failed to execute 'registerProtocolHandler' on 'Navigator':
Can only register custom handler in the document origin.
This also happens if I include it in the contents of the script, as suggested here
install_protocol.html
<head>
<title>Web Protocol Handler Sample - Register</title>
<script type="text/javascript">
navigator.registerProtocolHandler("burger",
"http://www.google.co.uk/?uri=%s",
"Burger handler");
</script>
</head>
I also tried calling it in my background.js script, where it did not throw an error, however the protocol does not seem to respond.
.
Could you please explain how to go through the process of registering and using a custom protocol in Chrome?
source
share