![Paul Irish](https://web.dev/images/authors/paulirish.jpg) Paul Irish [X](https://twitter.com/paul_irish) [GitHub](https://github.com/paulirish) [Mastodon](https://toot.cafe/@paul_irish) [Bluesky](https://bsky.app/profile/paul.irish) [Homepage](https://www.paulirish.com/)

<br />

If you use Gmail you may become frustrated when you click a `mailto:` link by accident and now your desktop client of Outlook or Mail starts up.

Thanks to `navigator.registerProtocolHandler()` ([which we've covered here before](https://web.dev/articles/registering-a-custom-protocol-handler)) you can wire up Gmail as your default mail client for all `mailto:` links in Chrome and Firefox.
![Use Gmail popup screenshot](https://developer.chrome.com/static/blog/getting-gmail-to-handle-all-mailto-links-with-registerprotocolhandler/image/use-gmail-popup-screensho-530bf09a908fb.jpg)

Here's how:

1. First, open up a Gmail tab. You **must** do this from the Gmail tab, not your html5rocks one. :)
2. Open your javascript console (`cmd-opt-j` on Mac, `ctrl-shift-j` on Windows) and enter:
3. `navigator.registerProtocolHandler("mailto", "https://mail.google.com/mail/?extsrc=mailto&url=%s", "Gmail");`
4. Accept the confirmation from the browser.
5. Click [this mailto: link](mailto:yourbestfriend@example.com?subject=registerProtocolHandler()+FTW!&amp;body=Check+out+what+I+learned+at+http://updates.html5rocks.com/2012/02/Getting-Gmail-to-handle-all-mailto-links-with-registerProtocolHandler%0A%0APlus,+flawless+handling+of+the+subject+and+body+parameters.+Bonus+from+RFC+2368!) to test out your new Gmail mailto hookup!

Boom. Enjoy.

If you ever need to removing this setting, you can do that at `chrome://settings/handlers` in Chrome and `Preferences->Applications->mailto` in Firefox.