The following code supposes to open a URL in an external app:
var a = document.createElement('a'); a.href = 'myprotocol:jdoe@example.com;fromuser=John%20Doe;mode=audiovideo'; document.body.appendChild(a); a.click();
When the app is not installed, on some PCs Chrome fails silently while on the others it displays this window:
Where is this behavior defined?
1 Answers
Answers 1
Application association to URI Schema
If you want to register your app to handle a specific URI Schema in Windows, then you should register it in registry. It is explained in MSDN article and Googling "Registering an Application to a URI Scheme" gives plenty of examples.
HKEY_CLASSES_ROOT/ your-protocol-name/ (Default) "URL:your-protocol-name Protocol" URL Protocol "" shell/ open/ command/ (Default) PathToExecutable
Web App schema registration
You can register a custom protocol handler with Google Chrome using navigator.registerProtocolHandler
(Firefox has the feature too).
navigator.registerProtocolHandler( 'web+mystuff', 'http://example.com/rph?q=%s', 'My App');
Please note, that your protocol has to start with web+
. Otherwise you would get SECURITY_ERR: DOM Exception 18
error.
Or, if you are developing a Chrome App, then you can register your handlers in your manifest file.
"url_handlers": { "view_foo_presentation": { "matches": [ "https://www.foo.com/presentation/view/*" ], "title": "View Foo presentation" } }
You can also look into the Chrome URLs (chrome://chrome-urls/
) and see if you can change it in any of the settings.
0 comments:
Post a Comment