Home > Uncategorized > Handle custom Url schemes in Chrome / Firefox

Handle custom Url schemes in Chrome / Firefox

If you want to be the go-to site to handle common url schemes (protocols), such as a Gmail wants to handle mailto: links, and so forth, then you can prompt the user to accept your website as the default handler for common uri schemes, using this simple code:

try
{
navigator.registerProtocolHandler(“protocol”, “http://www.yourdomain.com/?to=%s”, “Your site”);
} catch (ex) { }

The Try / Catch is just there for older browsers, or Internet explorer. The script has to be executed from the same domain as mentioned in the protocol handler. Otherwise it’ll be just flatly ignored.

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: