title: redirect to appstore or google play
body: <p>I will send my clients the link for the app in the following format</p>
  
  <p><a href="http://goo.gl.com/downloadtheapp" rel="noreferrer">http://goo.gl.com/downloadtheapp</a> (or whatever)</p>
  
  <p>I want this file be somewhere on my server that includes java script code that checks what is the device type and redirects to the convenient store. that is, google play if the device was android based and appstore if the device was ios based.</p>
  
  <p>till now I tried this, but it does not work.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type="text/javascript"&gt;
          $(document).ready(function () 
      {
          if(navigator.userAgent.toLowerCase().indexOf("android") &gt; -1)
          {
              window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&amp;hl=en';
          }
          if(navigator.userAgent.toLowerCase().indexOf("iphone") &gt; -1)
          {
              window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
          }
      }
  &lt;/javascript&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>