How to detect browser's protocol handlers?

This would be a very, very hacky way to do this... but would this work?

  • Put the link in as normal...
  • But attach an onclick handler to it, that sets a timer and adds an onblur handler for the window
  • (in theory) if the browser handles the link (application X) will load stealing the focus from the window...
  • If the onblur event fires, clear the timer...
  • Otherwise in 3-5seconds let your timeout fire... and notify the user "Hmm, looks like you don't have the Mega Uber Cool Application installed... would you like to install it now? (Ok) (Cancel)"

Far from bulletproof... but it might help?


There's no great cross-browser way to do this. In IE10+ on Win8+, a new msLaunchUri api enables you to launch a protocol, like so:

navigator.msLaunchUri('skype:123456', 
  function() 
  { 
    alert('success');
  }, 
  function()
  {
    alert('failed');
  } 
); 

If the protocol is not installed, the failure callback will fire. Otherwise, the protocol will launch and the success callback will fire.

I discuss this topic a bit further here: https://web.archive.org/web/20180308105244/https://blogs.msdn.microsoft.com/ieinternals/2011/07/13/understanding-protocols/

This topic is of recent (2021) interest; see https://github.com/fingerprintjs/external-protocol-flooding for discussion.


HTML5 defines Custom scheme and content handlers (to my knowledge Firefox is the only implementor so far), but unfortunately there is currently no way to check if a handler already exists—it has been proposed, but there was no follow-up. This seems like a critical feature to use custom handlers effectively and we as developers should bring attention to this issue in order to get it implemented.


There seems to be no straightforward way via javascript to detect the presence of an installed app that has registered a protocol handler.

In the iTunes model, Apple provides urls to their servers, which then provide pages that run some javascript:

http://ax.itunes.apple.com/detection/itmsCheck.js

So the iTunes installer apparently deploys plugins for the major browsers, whose presence can then be detected.

If your plugin is installed, then you can be reasonably sure that redirecting to your app-specific url will succeed.