title: How to avoid safari alert when redirecting to iTunes link
body: <p>I am using the following piece of code for launching my app from safari. What I want is, when a user clicks on the link from safari, it will launch my app, and If the app is not installed in device, safari will redirect to the iTunes link of that particular app.</p>
  
  <pre><code>   setTimeout(function() {
    window.location = "http://itunes.com/apps/myappname";
  }, 25);
  
  // If "custom-uri://" is registered the app will launch immediately and your
  // timer won't fire. If it's not set, you'll get an ugly "Cannot Open Page"
  // dialogue prior to the App Store application launching
  window.location = "custom-uri://";
  </code></pre>
  
  <p>Everything is working fine, except safari showing an error alert before redirecting to the iTunes link (if the app is not installed in device).</p>
  
  <blockquote>
    <p>"Safari cannot open this page, because the address is invalid".</p>
  </blockquote>
  
  <p>As it is a bad user experience, is there any way that I can suppress or avoid this popup before redirecting to the iTunes link.?</p>