title: JavaScript - how to detect if the Custom URL scheme is available or not available?
body: <p>In Windows operating system i have a custom URI scheme, which is used from </p>
  
  <blockquote>
    <p>IE, Firefox, Opera, Safari, Google Chrome</p>
  </blockquote>
  
  <p>to launch Juniper router VPN SSH client (like Cisco). Basically it works as below if the SSH Client is installed, from the web page VPN SSH Client can be launched.</p>
  
  <pre><code>&lt;a href="juniper:open"&gt; VPN SSH Client &lt;/a&gt;
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>sometimes the user did not installed the Juniper router SSH client application from the CD/DVD box, therefore the juniper:open does nothing. </p>
  
  <p>So in that case, i need to detect weather or not the URL scheme is available. </p>
  
  <p>Therefore, I tried Javascript method but its not working exactly. because the juniper:open is actually not web link. </p>
  
  <p>How do i then detect it please?</p>
  
  <pre><code>&lt;script&gt;
  // Fails
  function test1(){
    window.location = 'juniper:open';
    setTimeout(function(){
      if(confirm('Missing. Download it now?')){
        document.location = 'https://www.junper-affiliate.com/setup.zip';
      }
    }, 25);
  
    //document.location = 'juniper:open';
  }
  
  // Fails
  function test2(h){
    document.location=h;
    var time = (new Date()).getTime();
    setTimeout(function(){
     var now = (new Date()).getTime();
     if((now-time)&lt;400) {
      if(confirm('Missing. Download it now?')){
       document.location = 'https://www.junper-affiliate.com/setup.zip';
      } else {
       document.location=h;
      }
     }
    }, 300);
   }
  &lt;/script&gt;
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>&lt;a onclick="test1()"&gt;TEST 1&lt;/a&gt;
  &lt;a href="juniper:open" onclick="test2(this.href);return false;"&gt;TEST 2&lt;/a&gt;
  </code></pre>