Thursday, December 20, 2012

navigator.registerProtocolHandler()

Register a protocol scheme like:
navigator.registerProtocolHandler(
    'web+mystuff', 'http://example.com/rph?q=%s', 'My App');
The first parameter is the protocol. The second is the URL pattern of the application that should handle this scheme. The pattern should include a '%s' as a placeholder for data and it must must be on the same origin as the app attempting to register the protocol. Once the user approves access, you can use this link through your app, other sites, etc.:
<a href="web+mystuff:some+data">Open in "My App"</a>
Clicking that link makes a GET request to http://example.com/rph?q=web%2Bmystuff%3A:some%20data. Thus, you have to parse qparameter and manually strip out data from the protocol.

References:



No comments: